iahngy Posted March 27, 2013 Share Posted March 27, 2013 Hi, Would anyone help me for a basic function of sorting an array? I am in need of the very basic one so I can edit it for a display of many lines with comparisons. The _arraysearch is so complex to edit. I m in middle of the week of so many things...argh...I m very appreciated if i can it for the moment. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2013 Moderators Share Posted March 27, 2013 iahngy,_arraysearch is so complex to editI am sure we can help you with the syntax for _ArraySort so that you can use it directly. What is the array and how do you want to sort it? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
iahngy Posted March 27, 2013 Author Share Posted March 27, 2013 Hi Melba,for ex, I hve this array, Local $avArray[10] = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]I found some sort logic but ...need to change syntax to AutoIt.http://www.sorting-algorithms.com/bubble-sort Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2013 Moderators Share Posted March 27, 2013 iahngy, Why reinvent the wheel? #include <Array.au3> Local $avArray[10] = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ; Sort ascending _ArraySort($avArray) _ArrayDisplay($avArray) ; Sort descending _ArraySort($avArray, 1) ; Set the $iDescending parameter _ArrayDisplay($avArray) Does that not do the job adequately? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
iahngy Posted March 27, 2013 Author Share Posted March 27, 2013 Melba, I need a simple one so i keep track of the index of the item when being swapped around. Would be awesome if i hve the code soon? hehehe... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2013 Moderators Share Posted March 27, 2013 iahngy, Store an index into another dimension so that it remains linked to the value: #include <Array.au3> Local $avArray[10] = [9, 0, 8, 1, 7, 2, 6, 3, 5, 4] ; Create the indexed array $iCount = UBound($avArray) Local $aArray_Indexed[$iCount][2] For $i = 0 To $iCount - 1 $aArray_Indexed[$i][0] = $avArray[$i] ; The value $aArray_Indexed[$i][1] = $i ; Its index in the original array Next _ArrayDisplay($aArray_Indexed, "Original") ; Sort ascending _ArraySort($aArray_Indexed) _ArrayDisplay($aArray_Indexed, "Ascending") ; Sort descending _ArraySort($aArray_Indexed, 1) ; Set the $iDescending parameter _ArrayDisplay($aArray_Indexed, "Descending") Happy now? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jdelaney Posted March 27, 2013 Share Posted March 27, 2013 (edited) Add a second dimention with the original sorts: #include <Array.au3> Dim $avArray[10] = [9,8,7,6,5,4,3,2,1,0] Dim $avArray2[UBound($avArray)][2] For $i = 0 To UBound($avArray)-1 $avArray2[$i][0]=$avArray[$i] $avArray2[$i][1]=$i Next _ArrayDisplay($avArray2, "Presort") _ArraySort($avArray2) _ArrayDisplay($avArray2, "Postsort") edit: beat me to it Edited March 27, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
kylomas Posted March 27, 2013 Share Posted March 27, 2013 edit: beat me to it I know, are we sure that M23 is not a robot? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
iahngy Posted March 27, 2013 Author Share Posted March 27, 2013 Thank you Melba and Jd. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2013 Moderators Share Posted March 27, 2013 kylomas,If you are not more respectful I may have to "exterminate" you. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
kylomas Posted March 27, 2013 Share Posted March 27, 2013 (edited) ...bowing in submission... SSHHH, trying to find Dr. Who on speed dial.... Edited March 27, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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