Jump to content

Fastest ListView Sort & Populate


Recommended Posts

I needed to make a new script for a project and I reused code I used a while back. Back then I used .ini files with the INI functions to populate a listview of about 2500 records with 7 columns. This takes approximately 20 seconds to load the list.

Is there a faster way to populate a listview based on a file? Keep in mind that it there are multiple columns so some sort of FiletoArray may be possible but would I expect a performance upgrade?

---------------------

Also upon reading up on the lastest help file I ended up using the _GUICtrlListView_RegisterSortCallBack function for sorting, then I just use

$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $List
            _GUICtrlListView_SortItems($List, GUICtrlGetState($List))
    EndSwitch

so that it sorts when I click a column. This works fine but it takes about 10-20 seconds to actually sort the data.

Is there a faster function out there that I can use? I've tried to searching the forums but there is so much outdated information its hard to get a clear answer.

Also what are the current sorting methods using? Bubble sort? Quick sort? Quick sort 3? Radix?

I understand each method has their advantages, but QuickSort 3 was the best all around, last I checked. My data is very redundant. Its like 2300 zeros, and then 200 values would actually be different.

Edited by ParoXsitiC
Link to comment
Share on other sites

Have you looked at _GUICtrlListView_AddArray() ?

Edit: As for sorting, when I had big listviews that were taking too long to sort, I actually created two list views populated in two different orders, and then toggled visibility between the two, depending on which order was needed.

Of course, if you have multiple columns you want to sort on, that isn't really going to work as you need two list views for each order (ASC, DESC) for each column you want to sort, and you can quickly start consuming memory. Luckily in my case, I only had two columns and the only had to be sorted ascending.

Edited by ResNullius
Link to comment
Share on other sites

For lists of this magnitude, I use a SQLite database to store the records. I sort through SQL queries and simply clear the loaded list and replace it with the array results of the query. It will still take several seconds to sort a list of that magnitude, but no where near 20 seconds. Plus there is so much you can do with SQL queries that it seems pointless to write your own sorting algorithms.

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