# Sorting an array

## Recommended Posts

Dear all,

Is there a way to perform an array sort? I want to sort it according to the Hex addresses in it...

BTW - can it be sort with the bubble sort algorithm?

Here is what I have:

\$Myarray[1]="Filename1.abc"

\$Myarray[2]=3A90

\$Myarray[3]=3ABF

\$Myarray[4]="Filename4.abc"

\$Myarray[5]=0020

\$Myarray[6]=0417

\$Myarray[7]="Filename3.abc"

\$Myarray[8]=5800

\$Myarray[9]=FFFF

\$Myarray[10]="Filename5.abc"

\$Myarray[11]=0000

\$Myarray[12]=001F

\$Myarray[13]="Filename2.abc"

\$Myarray[14]=0540

\$Myarray[15]=0AFF

Here is what I need

\$Sorted[1]="Filename5.abc"

\$Sorted[2]=0000

\$Sorted[3]=001F

\$Sorted[4]="Filename4.abc"

\$Sorted[5]=0020

\$Sorted[6]=0417

\$Sorted[7]="Filename2.abc"

\$Sorted[8]=0540

\$Sorted[9]=0AFF

\$Sorted[10]="Filename1.abc"

\$Sorted[11]=3A90

\$Sorted[12]=3ABF

\$Sorted[13]="Filename3.abc"

\$Sorted[14]=5800

\$Sorted[15]=FFFF

##### Share on other sites

```#include <Array.au3>
Dim \$Myarray[5][3]

\$Myarray[0][0] = "Filename1.abc"
\$Myarray[0][1] = "3A90"
\$Myarray[0][2] = "3ABF"

\$Myarray[1][0] = "Filename4.abc"
\$Myarray[1][1] = "0020"
\$Myarray[1][2] = "0417"

\$Myarray[2][0] = "Filename3.abc"
\$Myarray[2][1] = "5800"
\$Myarray[2][2] = "FFFF"

\$Myarray[3][0] = "Filename5.abc"
\$Myarray[3][1] = "0000"
\$Myarray[3][2] = "001F"

\$Myarray[4][0] = "Filename2.abc"
\$Myarray[4][1] = "0540"
\$Myarray[4][2] = "0AFF"

_ArraySort(\$Myarray, 0, 0, 0, 3, 1)
For \$x = 0 To 4
\$msg = ""
For \$y = 0 To 2
\$msg &= \$Myarray[\$x][\$y] & @LF
Next
MsgBox(0, \$x, \$msg)
Next```

Edited by gafrost

Don't argue with an idiot; people watching may not be able to tell the difference.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...