Jump to content

Some questions about _ArraySort()


 Share

Recommended Posts

#Include <GuiListView.au3>

GUICreate('')
$list = GUICtrlCreateListView('1|2', 10, 10)

Dim $array[2][6], $result

$array[0][1] = 2
$array[0][2] = 5
$array[0][3] = 1
$array[0][4] = 4
$array[0][5] = 3

$array[1][1] = 'is'
$array[1][2] = 'example'
$array[1][3] = 'this'
$array[1][4] = 'sort'
$array[1][5] = 'a'

For $i = 1 To 5
    $result &= $array[0][$i] & ' - '
    $result &= $array[1][$i] & @CRLF
Next

MsgBox(0, 'Before', $result)

For $i = 1 To 5
    GUICtrlCreateListViewItem($array[0][$i] & '|' & $array[1][$i], $list)
Next

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($list) ]

_GUICtrlListViewSort($list, $B_DESCENDING, 0)

For $i = 1 To _GUICtrlListViewGetItemCount($list)
    $array[0][$i] = _GUICtrlListViewGetItemText($list, $i - 1, 0)
    $array[1][$i] = _GUICtrlListViewGetItemText($list, $i - 1, 1)
Next

$result = ''

For $i = 1 To 5
    $result &= $array[0][$i] & ' - '
    $result &= $array[1][$i] & @CRLF
Next

MsgBox(0, 'After', $result)

Edited by xcal
Link to comment
Share on other sites

@SmOke_N and all other users:

IT WORKS!!!

I found the right parameters with trial and error.

But i don't understand, why the 5th param must be 2.

I don't even understand the explanation for that parameter.

_ArraySort($s, 0, 1, 0, 2, 0)
Link to comment
Share on other sites

  • Developers

@SmOke_N and all other users:

IT WORKS!!!

I found the right parameters with trial and error.

But i don't understand, why the 5th param must be 2.

I don't even understand the explanation for that parameter.

_ArraySort($s, 0, 1, 0, 2, 0)
If you think of a 2 dimention Array as spreadsheet with rows and columns then the 5th param tells the sort routine which Array "column" to use to sort the row on.

:whistle:

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

Sure?

According to help file:

_ArraySort ( ByRef $a_Array [, $i_Descending [, $i_Base=0 [, $i_Ubound=0 [, $i_Dim=1 [, $i_SortIndex=0 ]]]]] )

The 6th param (= $i_SortIndex) "tells the sort routine which Array 'column' to use to sort the row on."

From help file: $i_SortIndex | Optional: The index to Sort on.

Today i played a lot with array's and _ArraySort() and i think, i'm getting it. Slowly :-)

Link to comment
Share on other sites

  • Developers

Sure?

According to help file:

_ArraySort ( ByRef $a_Array [, $i_Descending [, $i_Base=0 [, $i_Ubound=0 [, $i_Dim=1 [, $i_SortIndex=0 ]]]]] )

The 6th param (= $i_SortIndex) "tells the sort routine which Array 'column' to use to sort the row on."

From help file: $i_SortIndex | Optional: The index to Sort on.

Today i played a lot with array's and _ArraySort() and i think, i'm getting it. Slowly :-)

You are right ... the 5th param is the number of dimensions like Ubound($array,2) would return these days. so really the number of rows...

The UDF was written before this was available ...

:whistle:

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

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...