mIRC Homepage
Posted By: hkr Hash Tables Sorting - 14/04/07 08:43 AM
i skimmed over the forum but didn't found anyone else suggesting this. actually i'm trying to add some items to a hash table and alphabetize them. Tried coding into a mIRC Script, but with no success. it would be good to have this implemented wink. Also it would be good to have the ability to alphabetize the lines in a text/ini file (another suggestion)..
Posted By: RusselB Re: Hash Tables Sorting - 14/04/07 09:22 AM
Re: Hash tables - Use /hsave, /filter
Re: Text files - use /filter
Re: INI files - Not sure if /filter will work with them or not. Will check later.
Posted By: Om3n Re: Hash Tables Sorting - 14/04/07 02:37 PM
I dont see any possible advantage of alphanumeric sorting of hash tables, or even ini files.

The only way to achieve any level of hash table sorting (without somewhat defeating the purpose of using a hash table to begin with) is to lable the item names accordingly (i have often just used generic item names, a string of numbers, increasing each time something is added). To sort you simply have to use a /filter on the 'data' parts from the hash table, then write it back to the hash table line by line using a unique auto incrementing id as the item name (or any other ascending string). Check out /filter -k

Text files can easily be sorted with the use of /filter and /f* file commands.

Given the way ini files and read from and written to, it makes the order in which data is stored somewhat meaningless. I can not think of any reason for mirc to specifically implement and sorting function for it. However, you could most likely shove something together with the use of the $ini identifier. With the $ini identifier you can count the number of sections in an ini file... read the name of each section, sort them, then for each section you do the same with the item names, counting/reading/sorting, then use readini/writeini to rewrite the file in the new order. (actually, you can use this method on hash tables also, by sorting the saved ini file and reloading it after, but its certainly more effort than the other method)
Posted By: hixxy Re: Hash Tables Sorting - 14/04/07 02:37 PM
Hashtables are unsorted data storage methods, that's partly why they're so fast. I would just use a custom @window and sort that (either with /window -S or /filter)
Posted By: Riamus2 Re: Hash Tables Sorting - 14/04/07 02:44 PM
Originally Posted By: RusselB
Re: Hash tables - Use /hsave, /filter


Yep, that's how I sort my hash tables (for scores). It works very well to hsave the table and filter it (including original line number being added) and then using $hget on the line numbers going down the list. Of course, you can also just /filter it without caring about reusing the data in mIRC if you just want a text output of the data.
Posted By: hkr Re: Hash Tables Sorting - 14/04/07 06:29 PM
thxz, didn't think of /filter
Posted By: hkr Re: Hash Tables Sorting - 14/04/07 06:56 PM
btw can s.o. give me a simple example of alphabetic sorting with filter.. i got a bit confused crazy Do I use the alias comparing thing?

* Edit: actually, don't waste your time, i found sth else i'll do to accomplish what i intend to do.
Posted By: Riamus2 Re: Hash Tables Sorting - 14/04/07 08:33 PM
Just for anyone else... here's a good example from DaveC. That's a good start for figuring out how to do any kind of sorting of a hash table.
Posted By: hkr Re: Hash Tables Sorting - 15/04/07 10:32 AM
it actually might come in favour... on the second thought...
© mIRC Discussion Forums