Jump to content

Search the Community

Showing results for tags 'sorting'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 12 results

  1. Hello Everyone I have a strange issue ... The json generated array is not getting sorted properly for some reason #include <json.au3> #include <Array.au3> Dim $Chart[0][2] ; Array size of 2 columns $object = json_decode(FileRead("Test.json")) ;for local testing $Coins = json_get($object, '.data') for $i = 0 to UBound($Coins) -1 $name = json_get($object, '.data[' & $i & '].name' ) $change_1h = json_get($object, '.data[' & $i & '].quote.USD.percent_change_1h') _ArrayAdd($Chart,$name & "|" & number($change_1h,3) ) Next _ArraySort($Chart, 1, Default, Default, 1) _ArrayDisplay($Chart) _ArraySort is sorting the array like this (wrong): However if i click on the "Col 1" header it will be sorted correctly: How can i make _ArraySort sort them like clicking on "Col 1" does ? PS: i tried using the function "Number()" when i add the value to the array , but same result .. Thanks in advance Test.json
  2. Newbie to _GUICtrlListView_RegisterSortCallBack and can't get it to sort properly on date in format MM/DD/YYYY. Example code below. Q - How do I get the date to sort properly? ;#AutoIt3Wrapper_run_debug_mode=Y #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $g_id_ListView Example() Exit Func Example() Local $idRow1, $idRow2, $idRow3 GUICreate("ListView Sort Question", 300, 200) $g_id_ListView = GUICtrlCreateListView("Row#|Name|Date", 10, 10, 280, 180) $id_Row1 = GUICtrlCreateListViewItem("#1|Alice|01/15/2022", $g_id_ListView) $id_Row2 = GUICtrlCreateListViewItem("#2|Bob|02/22/2021", $g_id_ListView) $id_Row3 = GUICtrlCreateListViewItem("#3|Carol|03/13/2021", $g_id_ListView) $id_Row10 = GUICtrlCreateListViewItem("#10|Dave|10/09/2021", $g_id_ListView) $id_Row11 = GUICtrlCreateListViewItem("#11|Eve|11/21/2021", $g_id_ListView) GUISetState(@SW_SHOW) ;$vCompareType = 0 ;not ok as Row# sort #1, #10, and want #1, #2, ;$vCompareType = 1 ;not ok as Row# sort #1, #10, and want #1, #2, $vCompareType = 2 ;Row# okay but Date messed up _GUICtrlListView_RegisterSortCallBack($g_id_ListView, $vCompareType) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_id_ListView ;MsgBox(0,"","col="&GUICtrlGetState($g_id_ListView)) _GUICtrlListView_SortItems($g_id_ListView, GUICtrlGetState($g_id_ListView)) EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($g_id_ListView) GUIDelete($g_id_ListView) EndFunc ;Func Example()
  3. Hi and Hello from a Noob..:-) i have a very weird problem. I fill up a 2d array with a)numbers and b)letters from A-Z, so 2 columns. This works absolutely perfect. But as soon as i try to sort them (numbers ascending) the array ends up in some kind of "String-sortation". What exactly am i doin wrong? To make it easy, i post below the piece of code, which i am talking about. Hope that someone can help me out. Func Analyse() Local $BasisArray[0] Local $aFill = "A" & "|B" & "|C" & "|D" & "|E" & "|F" & "|G" & "|H" & "|I" & "|J" & "|K" & "|L" & "|M" & "|N" & "|O" & "|P" & "|Q" & "|R" & "|S" & "|T" & "|U" & "|V" & "|W" & "|X" & "|Y" & "|Z" _ArrayAdd ($BasisArray, $afill) Local $FreqArray[0][2]=[[]] $row = 0 For $i = 0 to 25 $fummel = _ArrayToString ($BasisArray, ":" , $row, $row) $readout = _GUICtrlRichEdit_GetText ($hRichEdit) $anzAs = stringreplace ($readout, $fummel, $fummel) $extended = @extended $FreqFill = $extended & "|" & $fummel _ArrayAdd($FreqArray, $FreqFill) $row = $row + 1 Next _ArrayDisplay($FreqArray, "2D - Item delimited") _ArraySort($FreqArray) _ArrayDisplay($FreqArray, "bla") Thanks for helping me, Cheers, Patrick
  4. Hello everyone, How can I display in ascending sequence some numbers stored in a string variable? $str = "18,03,48,23" MsgBox(0,"test",$str) I would like it to display "03,18,23,48"
  5. How to use _Excel_RangeSort to sort my excel file by three different headers Column A1, B1, and C1 have headers on which I want to sort by. The headers on which I want to sort are department, employee type, and name. I still really new to AutoIt so I do not actually know how to properly start this line or lines of code, to be honest. The example code is the best I can do. _Excel_RangeSort($OpenWorkbook, Default, "A1:C1", "1:1", $xlDescending, Default, $xlYes, Default, $xlSortRows) I just need to sort by those three headers in that order of department, employee type, and name, plus in descending order. any and all help would be greatly appreciated. Thank you!
  6. So I've made this script that detects how long i have held down my left mouse button for and stores the information in an array and then sorts its using _ArraySort but the output is half sorted half broken. Here's my script: HotKeySet("{F1}","_exit") #include <Misc.au3> #include <Timers.au3> #include <Array.au3> Local $dll = DllOpen("user32.dll") $on = False Global $array[0] While(1) If _IsPressed(01,$dll) Then $timer = _Timer_Init() While _IsPressed(01,$dll) Sleep(1) WEnd $time = _Timer_Diff($timer) _ArrayAdd($array,"Time: " & Floor($time) & " ms") ;~ ConsoleWrite("Time: " & Floor($time) & " ms" & @CRLF) EndIf Sleep(50) WEnd Func _exit() _ArraySort($array) _ArrayDisplay($array) Exit EndFunc And the output: See how its not sorted? What is the problem here?
  7. Hi, i'm just curious is there a way to sort an ini file after largest first? my inifiles writes itself like this 14=500 13=GREY 12=500 11=600 10=600 9=600 8=700 7=700 5=600 3=600 2=800 1=700 15=GREY 4=GREY but is there a way so i can get it sortet 15 14 13 12 etc?
  8. Hi everybody, i have a question related to strings items in an Array and sorting. Maybe someone can advice me how to solve the issue. I have an Array of strings, every item of the Array is as following: INFO [13.06.2017 11:48:01] [Thread-13] [ConGenImpUsb -> waitForConnection] INFO [07.06.2017 08:55:44] [main] MDU5 - Ver 5.1x I want to sort the item in the array by date and time, is there any function which allows me to sort by date/time? Thanks in advance
  9. This algorithm is loosely based on the Approximate Counting algorithm. After the user is prompted for a starting number, a "virtual coin flip" is performed. The numbers are then put in order from least to greatest. This is great for sorting. SmartCounting.au3
  10. I was reading the Helpfile on both GUICtrlRegisterListViewSort and _GUICtrlListView_SimpleSort, and after running my script, I was initially satisfied with the way columns are sorted when the user clicks on the column header. But at certain occasions, clicking on the column header to sort numbers - integers in particular - seem to have some unexpected behaviour. I cannot verify if it is due to the way I wrote the script, or because the functions used in AutoIt to sort numbers intentionally work the way they do. Example: Column ID | Item ID | Item Name | Date 1 | ID_1 | One | 14/05/2014 2 | ID_2 | Two| 14/05/2014 3 | ID_3 | Three| 14/05/2014 10 | ID_4 | Four| 14/05/2014 9 | ID_5 | Five| 14/05/2014 27 | ID_6 | Siz| 15/05/2014 When the user clicks Column ID, logically the order of ascending sorting would look like this: 1, 2, 3, 9, 10, 27 But what I got is like this: 1, 10, 2, 27, 3, 9 Does anyone know the reason behind the way it is sorted this way? How then do I get the columns to be sorted correctly when the user clicks the column header? (I did read across other related threads like and ) I attached my codes here to see if I might write them wrongly. My code for generating ListView: $inventoryList = GUICtrlCreateListView("ID|item id|item name| Date", 45, 140, expandGUIX(750), expandGUIY(450), $LVS_REPORT, BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) _GUICtrlListView_SetColumnWidth(-1, 3, 651) $hInventoryList = GUICtrlGetHandle($inventoryList) For $i = 0 To 3 _GUICtrlListView_SetColumnWidth($inventoryList, $i, $LVSCW_AUTOSIZE_USEHEADER) Next My code for auto-resizing columns: Func resizeColumns($hWnd, $listView, $iColumns, $iGUI_Width, $iGUI_Height) ; Check top index - if not 0 then we have a scroll bar so increase ListView width Local $iScroll_Allowance If _GUICtrlListView_GetTopIndex($listView) > 0 Then $iScroll_Allowance = 17 EndIf ; Determine ListView width Local $iLV_Width = $iScroll_Allowance Local $iData_Width, $iHeader_Width Local $i = 0 For $i = 0 To $iColumns - 1 ; Size column to fit header _GUICtrlListView_SetColumnWidth($listView, $i, $LVSCW_AUTOSIZE_USEHEADER) $iHeader_Width = _GUICtrlListView_GetColumnWidth($listView, $i) ; Now size column to fit data _GUICtrlListView_SetColumnWidth($listView, $i, $LVSCW_AUTOSIZE) $iData_Width = _GUICtrlListView_GetColumnWidth($listView, $i) ; If header is wider, reset width If $iHeader_Width > $iData_Width Then _GUICtrlListView_SetColumnWidth($listView, $i, $iHeader_Width) $iLV_Width += $iHeader_Width Else $iLV_Width += $iData_Width EndIf Next ; Resize ListView and GUI to fit data ControlMove($hWnd, "", $listView, 10, 10, $iLV_Width + 10, $iGUI_Height - 20) ; Add 10 for internal ListView borders EndFunc ;==>resizeColumns My code for locking users from resizing columns after auto-resize: Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Get details of message Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) ; Look for header resize code $iCode = DllStructGetData($tNMHEADER, "Code") Switch $iCode Case $HDN_BEGINTRACKW ; Prevent resizing Return True Case $LVN_COLUMNCLICK ; Sort column $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) $iCol = DllStructGetData($tInfo, "SubItem") _GUICtrlListView_SimpleSort($cListView, $g_bSortSense, $iCol) EndSwitch Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY
  11. I recently managed to make a ListView sort correctly by clicking on it's columns, it does sort items very well but there's a very annoying thing >_< : every time after the items are sorted out, an item gets focused ! After I click a column, one item gets blue'd, like when its selected, even if its not ! Note that this happens only becuase of this function : _GUICtrlListView_SimpleSort Instead, the _GUICtrlListView_SortItems function is not doing this , but because of my luck,I must use _GUICtrlListView_SimpleSort ( but it is faster ) Here's my script to test to see what I mean: #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> $Form1 = GUICreate("Form1", 383, 307, 192, 124) $ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) $ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1) GUISetState(@SW_SHOW) Global $toggle = 1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ListView1 _GUICtrlListView_SimpleSort($ListView1, $toggle, GUICtrlGetState($ListView1)) EndSwitch WEnd How could I get rid of this item focus ?
  12. How can I do to, when I click on on a specific column in a listview control, instead to get clicked/sorted other column. Is this possible ? I already know how to sort a column when I click on it : after the listview control was created, I add this code : _GUICtrlListView_RegisterSortCallBack(-1) I know that a gui can wait for a window event to happen, like a click on a control, but how can this be done to look if I clicked on a specific column and if so then, to sort (a clasic sort ) other column instead o.O ?
  • Create New...