Your implementation of Mel's sort algorithm has a problem in it.

After you read the ADC values in the "For CounterA = 0 to 9" loop, CounterA equals 10.

You then issue the "Gosub GetSort" statement.
Since CounterA = 10 the following line is pointing at memory locations beyond the RawData array.
"If RawData(CounterA+1) < RawData(CounterA) then"
This says If RawData(11) < RawData(10) then....
You need to set CounterA to 0 before calling GetSort.