On Thu, 12 Apr 2001, Craig Cassin wrote: > I suggest a simple bubble sort. > put the numbers in 4 registers say num1-num4 > compare num4 to num3. > if num3 is higher, swap the 2 registers. > if num 4 is higher, do nothing. > compare num4 and num3, num3 and num2, num2 and num1. > do this for three passes and your numbers are sorted, with the highest in > num4 and the lowest in num1. This requires 6 comparisons. There's another algorithm that only requires 5 comparisons. BTW, Here's a quick compare replace snippet: movf num1,w ; w = num1 subwf num2,w ; w = num2-num1 skpnc goto l1 ;num1 is greater so swap subwf num2,f ; num2 = num2-(num2-num1) = num1 addwf num2,w ; w = num1 + (num2-num1) = num2 movwf num1 ; num1 = num2 l1: Scott -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads