destruk
9 years agoStreaming Star
Note about the Sort custom routine
If your channel uses this code - usually located in generalUtils.brs - be sure to change your sort key values to either all upper case or all lower case first. Otherwise it will place "ZZ Top" in front of "Zombie" -- since "ZZ" is capitalized and the routine appears to sort based on the ASCII table of characters. (Capital letters have a lower numeric value than lowercase)
'******************************************************
'Insertion Sort
'Will sort an array directly, or use a key function
'******************************************************
Sub Sort(A as Object,key=invalid As dynamic)
If Type(A)<>"roArray" Return
If key=invalid
For i=1 To A.Count()-1
value=A[i]
j=i-1
While j>=0 And A[j]>value
A[j+1]=A[j]
j=j-1
End While
A[j+1]=value
Next
Else
If Type(key)<>"Function" Return
For i=1 To A.Count()-1
valuekey=key(A[i])
value=A[i]
j=i-1
While j>=0 And key(A[j])>valuekey
A[j+1]=A[j]
j=j-1
End While
A[j+1]=value
Next
End If
End Sub