Adds a new command called BubbleSort
Syntax
BubbleSort Array, Elements, Direction
Overview
Performs a bubble sort on N number of elements on a byte array in either direction.
Operators
Array – any Byte array
Elements - a constant, or byte variable indicating the number of elements within the array to sort
Direction - a constant, or byte variable indicating the direction of sorting 0 or 1. Any number > 0 will be taken as 1. 1 = high numbers first, 0 = low numbers first
Code:
Include "proton_4.inc""
Dim myarray[10] As Byte
Dim index As Byte
For index = 0 To 9
myarray[index] = index
HRSOut Dec myarray[index],", "
Next
HRSOut 13,10
index = 1
BubbleSort myarray, 10, index
For index = 0 To 9
HRSOut Dec myarray[index],", "
Next
HRSOut 13,10
index = 10
BubbleSort myarray, index, 0
For index = 0 To 9
HRSOut Dec myarray[index],", "
Next
HRSOut 13,10
Stop
Download module
Download: Bubble Sort 

Menu
Recent Articles


Using PDS with SPI GLCD based on ST7565R Controller
Graphic LCDs based on the ST7565 are cheaper then GLCDs with other controllers. SPI requires only four pins. If the circuit