# Bubble Sort

This example implements the Bubble Sort Algorithm. It shows how to sort a block of data in SRAM using the Bubble Sort Algorithm. The sorting algorithm is quite slow but space efficient. The algorithm first copies a 60 byte block of data from program memory to SRAM, then sorts the data.

See the application note: [AN0939 | Application Note | Microchip Technology AVR220: Bubble Sort][1] for implementation details.

## Processor: ATtiny 2313

This example was compiled for the 2313 and may give incorrect results on other processors.*\
The first 600 cycles transfer the data from program memory to SRAM, then the sorting begins. The example takes 21,475 cycles to complete.
    
The data to be sorted is stored in ram starting at location 0x60, then sorted in place.

*_For example, if run on the ATmega238, this location is in the I/O memory rather than sram. Values in I/O memory may be masked._


[1]: https://www.microchip.com/en-us/application-notes/an0939
