rony2006 Posted April 4, 2019 Posted April 4, 2019 (edited) Hello, I have a problem: Basically i want to sort a 2d array using one column that contains numeric values. My code looks like this: For $iz = 1 To UBound($CCinvoices) -1 $CCinvoices[$iz][1] = StringReplace($CCinvoices[$iz][1], " ", "") $CCinvoices[$iz][1] = Number($CCinvoices[$iz][1]) Next _Arraydisplay($CCinvoices, "$CCinvoices") _ArraySort($CCinvoices, 1, 0, 0,1) _Arraydisplay($CCinvoices, "$CCinvoices") This is how array looks before sorting. After i sort the array, I got the following result: As you see 227.21 was sorted after 29.79 so i dont know why i got this. I tried the following solutions: 1) Removing blank spaces 2) Converting strings to Number before sorting. Any ideas? Edited April 4, 2019 by rony2006
Moderators Melba23 Posted April 4, 2019 Moderators Posted April 4, 2019 rony2006, Converting the strings to numbers should give you a numerical sort. Can you please post the code that you used to convert the column - perhaps that might be helpful to see where it has gone wrong. 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: Reveal hidden contents 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
Gianni Posted April 4, 2019 Posted April 4, 2019 rony2006 , if your conversion loop is that in the first post (For $iz = 1 to ...), you should try to start the for/next loop from 0 instead of from 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
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