Jump to content
Sign in to follow this  
BlueScreen

Sorting an array

Recommended Posts

BlueScreen

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 :P

$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 this post


Link to post
Share on other sites
GaryFrost

#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

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×