Sometimes i have the problem that an array is not sorted. So I wrote a little subroutine that solves exactly this problem. This example is for sorting numbers. The example at the end is for strings.

 ```dim zahlen(10) zahlen(1)=10 zahlen(2)=0.10 zahlen(3)=5 zahlen(4)=3 zahlen(5)=8 zahlen(6)=55 zahlen(7)=10777 zahlen(8)=22 zahlen(9)=0.0001 zahlen(10)=1034 sorting_array(zahlen(),"desc") sub sorting_array(zahlen(),order\$) // Asc or DESC if (order\$="asc") then for k =1 to arraysize(zahlen(),1) for i =1 to arraysize(zahlen(),1) if (i=arraysize(zahlen(),1)) then break endif if (zahlen(i) > zahlen(i+1) ) then temp = zahlen(i) zahlen(i) = zahlen(i + 1) zahlen(i + 1) = temp endif next i next k elseif (order\$="desc") then for k =1 to arraysize(zahlen(),1) for i =1 to arraysize(zahlen(),1) if (i=arraysize(zahlen(),1)) then break endif if (zahlen(i) < zahlen(i+1) ) then temp = zahlen(i) zahlen(i) = zahlen(i + 1) zahlen(i + 1) = temp endif next i next k endif end sub for i=1 to arraysize(zahlen(),1) print zahlen(i) next i ```

This example is for strings. It is sorting upper case frist, then lower case by option asc. By option desc the upper case strings are at the end.

 ```dim text\$(10) text\$(1)="gert" text\$(2)="google" text\$(3)="Firefox" text\$(4)="Android" text\$(5)="ZigBee" text\$(6)="Hubert" text\$(7)="Hello" text\$(8)="Alfred" text\$(9)="Batman" text\$(10)="Robin" sorting_array(text\$(),"asc") sub sorting_array(text\$(),order\$) // Asc or DESC if (order\$="asc") then for k =1 to arraysize(text\$(),1) for i =1 to arraysize(text\$(),1) if (i=arraysize(text\$(),1)) then break endif if (text\$(i) > text\$(i+1) ) then temp\$ = text\$(i) text\$(i) = text\$(i + 1) text\$(i + 1) = temp\$ endif next i next k elseif (order\$="desc") then for k =1 to arraysize(text\$(),1) for i =1 to arraysize(text\$(),1) if (i=arraysize(text\$(),1)) then break endif if (text\$(i) < text\$(i+1) ) then temp\$ = text\$(i) text\$(i) = text\$(i + 1) text\$(i + 1) = temp\$ endif next i next k endif end sub for i=1 to arraysize(text\$(),1) print text\$(i) next i ```