' Comb Sort ' an optimized (8/2017 by twofingers@TBS) version of aCombSort for strings. ' It sorts the array S$() and needs the number of elements to sort (STop) ' Usage: CombSort STop ' ' It takes 330ms (or less) for an array of 100 elements ' System: MM2/48MHz/MMBasic 5.04.05 ' Sub CombSort(STop) Local string M$ Local integer i, h, T=1, F=0, sw Local float Gap=STop, Shrink=1.3 Do While Gap>1 Or Sw Gap=Int(Gap/Shrink) If Gap<1 Then Gap=1 i=1:Sw=F For h=i+Gap To STop If S$(i)>S$(h) Then M$=S$(i):S$(i)=S$(h):S$(h)=M$:Sw=T EndIf i=i+1 Next Loop End Sub