Jump to content

_ArraySort two dims doesnt seem to work


Recommended Posts

_ArraySort in two dimensions. I keep on trying to get this to work. But try as I may somehow I think it simply don't work. Can someone either provide a worked example, or admit defeat. If the latter then I may start to work on this.

Link to comment
Share on other sites

  • Developers

_ArraySort in two dimensions. I keep on trying to get this to work. But try as I may somehow I think it simply don't work. Can someone either provide a worked example, or admit defeat. If the latter then I may start to work on this.

Please read the sticky at the top of the BUGs forum or post first in Support when you are not sure.

All info for a Bug report is missing so moving to Support forum.

Here is an example I have posted before that demonstrates a 2 dimension Array sorting:

#include <Array.au3>

Dim $avArray[10][2]
$avArray[0][0] = "JPM"
$avArray[1][0] = "Holger"
$avArray[2][0] = "Jon"
$avArray[3][0] = "Larry"
$avArray[4][0] = "Jeremy"
$avArray[5][0] = "Valik"
$avArray[6][0] = "Cyberslug"
$avArray[7][0] = "Nutster"
$avArray[8][0] = "Tylo"
$avArray[9][0] = "JdeB"
For $x = 0 To 9
    $avArray[$x][1] = $x
Next

; Sort on first dim
ConsoleWrite("*** Sort on first dimension" & @LF)
_ArraySort($avArray, 0, 0, 0, 2, 0)
DisplayArray($avArray)
; Sort on second dim to restore original order
ConsoleWrite("*** Sort on second dimension, restore original order" & @LF)
_ArraySort($avArray, 0, 0, 0, 2, 1)
DisplayArray($avArray)

Func DisplayArray($array)
    For $x = 0 To 9
        ConsoleWrite($avArray[$x][0] & " - " & $avArray[$x][1] & @LF)
    Next
EndFunc;==>DisplayArray
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 weeks later...

Jdeb, thanks for coming back on this - much appreciated. Your example works just fine. I am trying to extend the example to make sure I really understand what is going on and why I did not understand it better before. If I get somewhere with something useful I will post back here.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...