Jump to content

How to sort a 2D array?


Recommended Posts

Hi,

I'm trying to sort a 2D array:

[0]|Microsoft Windows|XP|x86|German

[1]|Microsoft Windows|XP|x86|English_US

[2]|Microsoft Windows|General|x86|German

[3]|Microsoft Windows|General|x86|English_US

[4]|Microsoft Windows|General|x86|Global

[5]|Microsoft Windows|Vista|x64|Global

[6]|Microsoft Windows|Vista|x86|Global

[7]|Microsoft Windows|2000|x86|German

[8]|Microsoft Windows|2000|x86|English_US

[9]|Microsoft Office|2007|x64|Global

[10]|Microsoft Office|2007|x86|Global

[11]|Microsoft Office|2003|x86|German

[12]|Microsoft Office|2003|x86|English_US

[13]|Microsoft Office|2003|x86|Global

[14]|Microsoft Windows|Server 2003|x64|German

[15]|Microsoft Windows|Server 2003|x64|English_US

[16]|Microsoft Windows|Server 2003|x64|Global

[17]|Microsoft Windows|Server 2003|x86|German

[18]|Microsoft Windows|Server 2003|x86|English_US

When using _ArraySort() I only can select ONE column.

But I would like to sort starting from column 0 to the last column.

Any ideas?

Greet,

-supersonic.

Link to comment
Share on other sites

  • Developers

Not sure whats not working but you can define on which column you want to sort.

Show us the code that doesn't work.

Jos

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

The function _ArraySort() works so far.

After sorting column 0 I sort column 1. By doing so column 0 gets unsorted.

I looking for a way to fix the sort order of a column.

Not sure whats not working but you can define on which column you want to sort.

Show us the code that doesn't work.

Jos

Link to comment
Share on other sites

  • Developers

The function _ArraySort() works so far.

After sorting column 0 I sort column 1. By doing so column 0 gets unsorted.

I looking for a way to fix the sort order of a column.

Correct, so you do as suggested and add a extra column in which you concatenate the values in the sequence they need to be sorted and sort on that column.

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

This maid be a solution but I don't get a clue on it.

When you look at the array I posted above you can see that nearly each line have to be sorted a other way.

If using a static sort schema for each line in the array you mix it up.

Maybe you have example code to understand better...?

Concatenate fields in desired column order to 1-D array (keep delimiter | ), sort 1-D array, split sorted array...

Edited by supersonic
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...