Der_Andi Posted February 4, 2007 Share Posted February 4, 2007 (edited) Hi, I don't get the how-to-use of the parameters $i_Ubound and $i_Dim. Maybe someone could explain me. Some simple examples would be nice, too. I want to sort an array, that is created by reading in a section from an ini file. Thus, there are 2 dimensions. The 1st dimension contains always numbers. The array should be sorted by the 1st dimension ascending. The 2nd dimension must be sorted like the 1st dimension. The allocation of the data must not be lost. The $array[0][0] is not being sorted. The size of the array is always different, but the 2 dimensions are always the same size. Andi Edited February 4, 2007 by Der_Andi Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 Hi, I don't get the how-to-use of the parameters $i_Ubound and $i_Dim. Maybe someone could explain me. Some simple examples would be nice, too. I want to sort an array, that is created by reading in a section from an ini file. Thus, there are 2 dimensions. The 1st dimension contains always numbers. The array should be sorted by the 1st dimension ascending. The 2nd dimension must be sorted like the 1st dimension. The allocation of the data must not be lost. The $array[0][0] is not being sorted. The size of the array is always different, but the 2 dimensions are always the same size. AndiCare to post some code and what you're trying to get out of it? So maybe we aren't waisting our time having to write it all out for you? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
brodie28 Posted February 4, 2007 Share Posted February 4, 2007 Care to post some code and what you're trying to get out of it? So maybe we aren't waisting our time having to write it all out for you?I gave more information in my other topic and you linked me here SmokeN Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 I gave more information in my other topic and you linked me here SmokeNI linked you here because it was the same type of question. A question without any effort shown on either part, with the assumption there is a magic function to just do it, however if there was, you'd already be using it, so both of you posted a question with no code for anyone to work out a solution. Both of you just assume we will either A.) have a link or a function to post if we understand what your question is, or B.) care so little about those that help here, that you just assume we love to write out our own scenario's in helping you, rather than using the information you should have provided in the first place to get a speedy solution. My reference in the other was telling you about _ArraySortNum() and here: http://www.autoitscript.com/forum/index.ph...st&p=302145 I even posted a solution to your date issue, which I've shown you how to mod your other questions. But you probably want me to make my own scenario, you have 4 elements in the first dimension of the array to begin with (assuming [4][N] is date, and [3][N] is some other number other than a date, you've now asked questions on element 3 and element 4... are there more on elements 1 and 2? Now that I've successfully hijacked this thread... my apologies to the OP, but of course some of this applied to them as well. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
brodie28 Posted February 4, 2007 Share Posted February 4, 2007 Basically, my array looks like this. $targets[3][1] = 8465156 $targets[3][2] = 4558454 $targets[3][3] = 545848484 $targets[3][4] = 5484848421 $targets[3][5] = 84887584 $targets[3][6] = 847875154 $targets[3][7] = 5848451 $targets[3][8] = 548442457 $targets[3][9] = 847545457 $targets[3][10] = 758454 $targets[3][11] = 7545454 I need to sort the array so on that index ([3][$i]) the numbers are in ascending order. _Arraysort should be able to do this but I am not sure how. $targets[3][12] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 (edited) Basically, my array looks like this. $targets[3][1] = 8465156 $targets[3][2] = 4558454 $targets[3][3] = 545848484 $targets[3][4] = 5484848421 $targets[3][5] = 84887584 $targets[3][6] = 847875154 $targets[3][7] = 5848451 $targets[3][8] = 548442457 $targets[3][9] = 847545457 $targets[3][10] = 758454 $targets[3][11] = 7545454 I need to sort the array so on that index ([3][$i]) the numbers are in ascending order. _Arraysort should be able to do this but I am not sure how. $targets[3][12]I would have assumed it would have looked like this:expandcollapse popup_ArraySort($targets, 1, 1, UBound($targets, 2) -1, UBound($targets, 2))oÝ÷ ضßÛ'¢Ü(®H§ú+æ§u·jë×bv}ý¶«{ljw~íÊÙ÷öÛ!£(¶¬z+azZl²¢wǺÚ"µÍÚ[ÛYH Ø^K]LÉÝÂ[H ÌÍÝÙ]ÖÍVÌLBÌÍÝÙ]ÖÌ×VÌWHH LMMÌÍÝÙ]ÖÌ×VÌHH MN MÌÍÝÙ]ÖÌ×VÌ×HH M N ÌÍÝÙ]ÖÌ×VÍHH M BÌÍÝÙ]ÖÌ×VÍWHH ÍN ÌÍÝÙ]ÖÌ×VÍHH Î ÍLMMÌÍÝÙ]ÖÌ×VÍ×HH N LBÌÍÝÙ]ÖÌ×VÎHH M MÂÌÍÝÙ]ÖÌ×VÎWHH ÍM M MÂÌÍÝÙ]ÖÌ×VÌLHH ÍN MÌÍÝÙ]ÖÌ×VÌLWHH ÍM M MÐ^QÜ^L ÌÍÝÙ]ÊBÐ^TÛÜ[L ÌÍÝÙ]ËËJBÐ^QÜ^L ÌÍÝÙ]ÊB[ÈÐ^TÛÜ[L TY ÌÍØ]^K ÌÍÚR[^ ÌÍÚPØÙ[HK ÌÍÚQ[Y[HK ÌÍÚPÙHH BRY ÌÍÚQ[Y[ ÝÈÜ ÌÍÚQ[Y[ ÈH[]Ù]ÜK ÌÎNÉÌÎNÊBRYÐ^J ÌÍØ]^JHH[]Ù]Ü ÌÎNÉÌÎNÊBSØØ[ ÌÍØP^RÛÕPÝ[ ÌÍØ]^K ÌÍÚQ[Y[WBRY ÌÍÚQ[Y[HH[BQÜ ÌÍÚPÐÈH ÌÍÚPÙHÈPÝ[ ÌÍØ]^KJHHBBBIÌÍØP^RÛÉÌÍÚPÐ×HH ÌÍØ]^VÉÌÍÚPÐ×VÉÌÍÚR[^BBS^BWÐ^TÛÜ[J ÌÍØP^RÛ ÌÍÚPØÙ[ ÌÍÚPÙJBBQÜ ÌÍÚPÐÈH ÌÍÚPÙHÈPÝ[ ÌÍØ]^KJHHBBBIÌÍØ]^VÉÌÍÚPÐ×VÉÌÍÚR[^HH ÌÍØP^RÛÉÌÍÚPÐ×BBS^Q[ÙBBQÜ ÌÍÚPÐÈH ÌÍÚPÙHÈPÝ[ ÌÍØ]^KHHBBBIÌÍØP^RÛÉÌÍÚPÐ×HH ÌÍØ]^VÉÌÍÚR[^VÉÌÍÚPÐ×BBS^BWÐ^TÛÜ[J ÌÍØP^RÛ ÌÍÚPØÙ[ ÌÍÚPÙJBBQÜ ÌÍÚPÐÈH ÌÍÚPÙHÈPÝ[ ÌÍØ]^KHHBBBIÌÍØ]^VÉÌÍÚR[^VÉÌÍÚPÐ×HH ÌÍØP^RÛÉÌÍÚPÐ×BBS^Q[YT] ÌÎNÉÌÎNÂ[[Â[ÈÐ^TÛÜ[JTY ÌÍÛ^K ÌÍÚPØÙ[[ÈHK ÌÍÚTÝHJBQÜ ÌÍÚPÛÝ[H ÌÍÚTÝÈPÝ[ ÌÍÛ^JHHBSØØ[ ÌÍÚTÑHH ÌÍÚPÛÝ[BRY ÌÍÚPØÙ[[ÈH[BBQÜ ÌÍÞÛÝ[H ÌÍÚPÛÝ[ÈPÝ[ ÌÍÛ^JHHBBBBRY[X ÌÍÛ^VÉÌÍÚTÑWJH È[X ÌÍÛ^VÉÌÍÞÛÝ[JH[ ÌÍÚTÑHH ÌÍÞÛÝ[BBS^BQ[ÙBBBQÜ ÌÍÞÛÝ[H ÌÍÚPÛÝ[ÈPÝ[ ÌÍÛ^JHHBBBBRY[X ÌÍÛ^VÉÌÍÚTÑWJH ÝÈ[X ÌÍÛ^VÉÌÍÞÛÝ[JH[ ÌÍÚTÑHH ÌÍÞÛÝ[BBS^BQ[YBSØØ[ ÌÍÚRH ÌÍÛ^VÉÌÍÚPÛÝ[BBIÌÍÛ^VÉÌÍÚPÛÝ[HH ÌÍÛ^VÉÌÍÚTÑWBBIÌÍÛ^VÉÌÍÚTÑWHH ÌÍÚRS^[[Â[ÈÐ^QÜ^L ÌÍØP^K ÌÍÜÕ]HH ÌÎNÐ^HÜ^H[IÌÎNË ÌÍÚPÙHHK ÌÍÜÕÐÛÛÛÛHH BRYÝÐ^J ÌÍØP^JH[]Ù]ÜK BSØØ[ ÌÍÜÒÛH ÌÎNÑ[Y[Ú[ÛHÎ ÌÎNÈ [ÈPÝ[ ÌÍØP^KJHLH [È ÌÎNÈ[[Y[ ÊIÌÎNÈ [È [ÈÂBBIÌÎNÑ[Y[Ú[ÛÎ ÌÎNÈ [ÈPÝ[ ÌÍØP^KHHH [È ÌÎNÈ[[Y[ ÊIÌÎNÈ [È [ÈQÜ ÌÍÚPÐÈH ÌÍÚPÙHÈPÝ[ ÌÍØP^KJHHBBQÜ ÌÍÞÐÈHÈPÝ[ ÌÍØP^KHHBBBIÌÍÜÒÛ [ÏH ÌÎNÖÉÌÎNÈ [È ÌÍÚPÐÈ [È ÌÎN×VÉÌÎNÈ [È ÌÍÞÐÈ [È ÌÎN×HH ÌÎNÈ [È ÌÍØP^VÉÌÍÚPÐ×VÉÌÍÞÐ×H [ÈBS^S^RY ÌÍÜÕÐÛÛÛÛH[]ÛÛÛÛUÜ]J [È ÌÍÜÒÛ BT]ÙÐÞ M ÌÍÜÕ]KÝ[Õ[TYÚ ÌÍÜÒÛJJB[[ Edited February 4, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
brodie28 Posted February 4, 2007 Share Posted February 4, 2007 That works fine as far as aranging the numbers goes... But it doesn't sort the rest of the array. $targets[3][$i] stores a number which relates to information in $targets[2][$i] and $targets[1][$i] and $targets[0][$i]. If one index gets sorted the rest need to be as well so that it still matches. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 That works fine as far as aranging the numbers goes... But it doesn't sort the rest of the array. $targets[3][$i] stores a number which relates to information in $targets[2][$i] and $targets[1][$i] and $targets[0][$i]. If one index gets sorted the rest need to be as well so that it still matches.So, do I need to do it all, or are you going to show you at least tried to do something? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
brodie28 Posted February 4, 2007 Share Posted February 4, 2007 I am hopeless at multi-dimensional arrays. If I could do it I wouldn't be here. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 I am hopeless at multi-dimensional arrays.If I could do it I wouldn't be here.Yeah, I suck at golf too, doesn't stop me fry "trying" though . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 (edited) *** My last effort *** only because I can see this possibly being useful, but I can also see where it would fail (Like if you have duplicate numbers).CODEexpandcollapse popupDim $targets[3][12] $targets[1][1] = 1 $targets[1][2] = 2 $targets[1][3] = 3 $targets[1][4] = 4 $targets[1][5] = 5 $targets[1][6] = 6 $targets[1][7] = 7 $targets[1][8] = 8 $targets[1][9] = 9 $targets[1][10] = 10 $targets[1][11] = 11 $targets[2][1] = 8465156 $targets[2][2] = 4558454 $targets[2][3] = 545848484 $targets[2][4] = 5484848421 $targets[2][5] = 84887584 $targets[2][6] = 847875154 $targets[2][7] = 5848451 $targets[2][8] = 548442457 $targets[2][9] = 847545457 $targets[2][10] = 758454 $targets[2][11] = 7545454 ;_ArrayDisplay2D($targets) ;_ArraySort($targets, 1, 1, UBound($targets, 2) -1, UBound($targets, 2), 3) _ArraySortNum2D($targets, 2, 0, 2, 1) _ArrayDisplay2D($targets) Func _ArraySortNum2D(ByRef $avArray, $iIndex, $iAscend = 1, $iDimen = 1, $iBase = 0) If $iDimen > 2 Or $iDimen < 1 Then Return SetError(1, 0, '') If IsArray($avArray) = 0 Then Return SetError(2, 0, '') Local $aArrayHold[UBound($avArray, $iDimen)], $aTempArray = $avArray If $iDimen = 1 Then For $iCC = $iBase To UBound($avArray, 1) - 1 $aArrayHold[$iCC] = $avArray[$iCC][$iIndex] Next _ArraySortNum($aArrayHold, $iAscend, $iBase) Local $iAdd = $iBase, $iUp = $iBase While $iAdd < UBound($avArray, 1) If $aArrayHold[$iAdd] = $avArray[$iUp][$iIndex] Then For $iCC = 1 To UBound($avArray, 2) - 1 $aTempArray[$iAdd][$iCC] = $avArray[$iUp][$iCC] Next $iUp = 0 $iAdd += 1 EndIf $iUp += 1 WEnd Else For $iCC = $iBase To UBound($avArray, 2) - 1 $aArrayHold[$iCC] = $avArray[$iIndex][$iCC] Next _ArraySortNum($aArrayHold, $iAscend, $iBase) Local $iAdd = $iBase, $iUp = $iBase While $iAdd < UBound($avArray, 2) If $aArrayHold[$iAdd] = $avArray[$iIndex][$iUp] Then For $iCC = 1 To UBound($avArray, 1) - 1 If $iCC = $iIndex Then $aTempArray[$iCC][$iAdd] = $aArrayHold[$iAdd] Else $aTempArray[$iCC][$iAdd] = $avArray[$iCC][$iUp] EndIf Next $iUp = 0 $iAdd += 1 EndIf $iUp += 1 WEnd EndIf $avArray = $aTempArray Return '' EndFunc Func _ArraySortNum(ByRef $nArray, $iAscending = 1, $iStart = 1) For $iCount = $iStart To UBound($nArray) - 2 Local $iSE = $iCount If $iAscending = 0 Then For $xCount = $iCount To UBound($nArray) - 1 If Number($nArray[$iSE]) < Number($nArray[$xCount]) Then $iSE = $xCount Next Else For $xCount = $iCount To UBound($nArray) - 1 If Number($nArray[$iSE]) > Number($nArray[$xCount]) Then $iSE = $xCount Next EndIf Local $iHLD = $nArray[$iCount] $nArray[$iCount] = $nArray[$iSE] $nArray[$iSE] = $iHLD Next EndFunc Func _ArrayDisplay2D($aArray, $sTitle = 'Array Display 2Dim', $iBase = 1, $sToConsole = 0) If Not IsArray($aArray) Then Return SetError(1, 0, 0) Local $sHold = 'Dimension 1 Has: ' & UBound($aArray, 1) -1 & ' Element(s)' & @LF & _ 'Dimension 2 Has: ' & UBound($aArray, 2) - 1 & ' Element(s)' & @LF & @LF For $iCC = $iBase To UBound($aArray, 1) - 1 For $xCC = 0 To UBound($aArray, 2) - 1 $sHold &= '[' & $iCC & '][' & $xCC & '] = ' & $aArray[$iCC][$xCC] & @LF Next Next If $sToConsole Then Return ConsoleWrite(@LF & $sHold) Return MsgBox(262144, $sTitle, StringTrimRight($sHold, 1)) EndFuncI changed the array up, numbered the 1st element / dimensions 1 - 11 so you could see it was in fact shifted correctly. My first effort at something like this, so if you think you can make it better, enjoy. Edited February 4, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 I know I said the one before was my last effort, but the duplicate thing was bothering me. This one looks much cleaner and allows for duplicates:CODEexpandcollapse popupDim $targets[3][12] $targets[1][1] = 1 $targets[1][2] = 2 $targets[1][3] = 3 $targets[1][4] = 4 $targets[1][5] = 5 $targets[1][6] = 6 $targets[1][7] = 7 $targets[1][8] = 8 $targets[1][9] = 9 $targets[1][10] = 10 $targets[1][11] = 11 $targets[2][1] = 8465156 $targets[2][2] = 4558454 $targets[2][3] = 545848484 $targets[2][4] = 5484848421; $targets[2][5] = 84887584 $targets[2][6] = 5484848421; $targets[2][7] = 5848451 $targets[2][8] = 548442457 $targets[2][9] = 847545457 $targets[2][10] = 758454 $targets[2][11] = 7545454 _ArraySortNum2D($targets, 2, 0, 2, 1) _ArrayDisplay2D($targets) Func _ArraySortNum2D(ByRef $avArray, $iIndex, $iAscend = 1, $iDimen = 1, $iBase = 0) If $iDimen > 2 Or $iDimen < 1 Then Return SetError(1, 0, '') If IsArray($avArray) = 0 Then Return SetError(2, 0, '') Local $aArrayHold[UBound($avArray, $iDimen)], $aTempArray = $avArray, $aASN If $iDimen = 1 Then For $iCC = $iBase To UBound($avArray, 1) - 1 $aArrayHold[$iCC] = $avArray[$iCC][$iIndex] Next $aASN = _ArraySortNum($aArrayHold, $iAscend, $iBase, 1) For $iCC = $iBase To UBound($avArray, 1) - 1 For $xCC = $iBase To UBound($avArray, 2) - 1 $aTempArray[$iCC][$xCC] = $avArray[$aASN[$iCC]][$xCC] Next Next Else For $iCC = $iBase To UBound($avArray, 2) - 1 $aArrayHold[$iCC] = $avArray[$iIndex][$iCC] Next $aASN = _ArraySortNum($aArrayHold, $iAscend, $iBase, 1) For $iCC = $iBase To UBound($avArray, 2) - 1 For $xCC = $iBase To UBound($avArray, 1) - 1 $aTempArray[$xCC][$iCC] = $avArray[$xCC][$aASN[$iCC]] Next Next EndIf $avArray = $aTempArray Return '' EndFunc Func _ArraySortNum(ByRef $nArray, $iAscending = 1, $iStart = 1, $iReturnIndexChange = 0) Local $aTempArray = $nArray For $iCount = $iStart To UBound($nArray) - 2 Local $iSE = $iCount If $iAscending = 0 Then For $xCount = $iCount To UBound($nArray) - 1 If Number($nArray[$iSE]) < Number($nArray[$xCount]) Then $iSE = $xCount Next Else For $xCount = $iCount To UBound($nArray) - 1 If Number($nArray[$iSE]) > Number($nArray[$xCount]) Then $iSE = $xCount Next EndIf Local $iHLD = $nArray[$iCount] $nArray[$iCount] = $nArray[$iSE] $nArray[$iSE] = $iHLD Next If $iReturnIndexChange = 0 Then Return '' Local $sHoldElement, $aReturnArray[UBound($nArray)] For $iCC = $iStart To UBound($nArray) - 1 For $xCC = $iStart To UBound($aTempArray) - 1 If $aTempArray[$xCC] = $nArray[$iCC] And _ StringInStr(Chr(1) & $sHoldElement, Chr(1) & $xCC & Chr(1)) = 0 Then $sHoldElement &= $xCC & Chr(1) $aReturnArray[$iCC] = $xCC ExitLoop EndIf Next Next Return $aReturnArray EndFunc Func _ArrayDisplay2D($aArray, $sTitle = 'Array Display 2Dim', $iBase = 1, $sToConsole = 0) If Not IsArray($aArray) Then Return SetError(1, 0, 0) Local $sHold = 'Dimension 1 Has: ' & UBound($aArray, 1) -1 & ' Element(s)' & @LF & _ 'Dimension 2 Has: ' & UBound($aArray, 2) - 1 & ' Element(s)' & @LF & @LF For $iCC = $iBase To UBound($aArray, 1) - 1 For $xCC = 0 To UBound($aArray, 2) - 1 $sHold &= '[' & $iCC & '][' & $xCC & '] = ' & $aArray[$iCC][$xCC] & @LF Next Next If $sToConsole Then Return ConsoleWrite(@LF & $sHold) Return MsgBox(262144, $sTitle, StringTrimRight($sHold, 1)) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Der_Andi Posted February 4, 2007 Author Share Posted February 4, 2007 (edited) Okay, this is what i want to do. Here's a section of my ini file: [Data] 200702032200=03.02.2007, 22:00|test1|15 200703151500=15.03.2007, 15:00|test2|10 200702040300=04.02.2007, 03:00|test3|3 A function in my script reads in this section, and if there are more than 1 entrys the array will be sorted ascending. The 2nd dimension should be sorted in the same way as the 1st to keep the allocation. So it looks like this: [Data] 200702032200=03.02.2007, 22:00|test1|15 200702040300=04.02.2007, 03:00|test3|3 200703151500=15.03.2007, 15:00|test2|10 Func _update() $s = IniReadSection($ini, "Data") If IsArray($s) Then If $s[0][0] > 1 Then _ArraySort($s, 0, 1, 0, $s[0][0]) EndIf ... EndFunc But the sort function fails. Scite console says: C:\...\AutoIt3\Include\Array.au3 (643) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $t = $array[$L][$x] $t = ^ ERROR It worked, when there were only 2 entries in the ini. Now there are 3 and sorting fails. What are the correct parameters in _ArraySort() ? Edited February 4, 2007 by Der_Andi Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 Okay, this is what i want to do. Here's a section of my ini file: [Data] 200702032200=03.02.2007, 22:00|test1|15 200703151500=15.03.2007, 15:00|test2|10 200702040300=04.02.2007, 03:00|test3|3 A function in my script reads in this section, and if there are more than 1 entrys the array will be sorted ascending. The 2nd dimension should be sorted in the same way as the 1st to keep the allocation. So it looks like this: [Data] 200702032200=03.02.2007, 22:00|test1|15 200702040300=04.02.2007, 03:00|test3|3 200703151500=15.03.2007, 15:00|test2|10 Func _update() $s = IniReadSection($ini, "Data") If IsArray($s) Then If $s[0][0] > 1 Then _ArraySort($s, 0, 1, 0, $s[0][0]) EndIf ... EndFunc But the sort function fails. Scite console says: It worked, when there were only 2 entries in the ini. Now there are 3 and sorting fails. What are the correct parameters in _ArraySort() ?_ArraySort($s, 0, 1, 0, $s[0][0] + 1) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Der_Andi Posted February 4, 2007 Author Share Posted February 4, 2007 _ArraySort($s, 0, 1, 0, $s[0][0] + 1) Sorry, does not work. Same error as shown above (in red). Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 4, 2007 Moderators Share Posted February 4, 2007 Sorry, does not work. Same error as shown above (in red).Hi Andi, I don't know if _ArraySort is broke on 2Dim but I can't get the damn thing to work no matter what I put in the parameters. Maybe someone else could give you a hand here. I would have thought: _ArraySort($s, 1, 1, $s[0][0], 2)Would have been correct from reading the param info. But I also get the subscript error. $sMsg = $sMsg & "[" & $iCounter & "]= " & StringStripCR($avArray[$iCounter]) & @CR $sMsg = $sMsg & "[" & $iCounter & "] = " & StringStripCR(^ ERRORThis is weird, because I'm showing it is 2 dim with 2 elements with the 2 in the 5th parameter, and the error looks like it's still looking for a 1 dimension array. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Der_Andi Posted February 4, 2007 Author Share Posted February 4, 2007 Well, so i will proceed like this: If $s[0][0] > 1 Then Dim $t[$s[0][0]+1] For $i = 1 To $s[0][0] $t[$i] = $s[$i][0] Next _ArraySort($t) EndIf Circumstantial, but successful. Link to comment Share on other sites More sharing options...
randallc Posted February 4, 2007 Share Posted February 4, 2007 Hi, If I understand, you may be trying to perform sort, then subsort? If so, you can get workaround using the subsort command in my udf ; try link from my sig for Array2D udf best, randall [PS there was a bug report some time back about ArraySort, but the parameters were a little different irl than you would expect, and I think not changed; can't remember the details] ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Der_Andi Posted February 4, 2007 Author Share Posted February 4, 2007 If I understand, you may be trying to perform sort, then subsort? Hi, there's no subsort. The whole array is sorted once on a specific column. Example: A 2dim-array. 1st | 2nd ====|==== 2 | is 5 | example 1 | this 4 | sort 3 | a After sort, it should look like this: 1st | 2nd ====|==== 1 | this 2 | is 3 | a 4 | sort 5 | example See? Link to comment Share on other sites More sharing options...
/dev/null Posted February 4, 2007 Share Posted February 4, 2007 After sort, it should look like this: 1st | 2nd ====|==== 1 | this 2 | is 3 | a 4 | sort 5 | example See? what kind of sort algorithm is that? PESS = Predictive english sentence sort? __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now