mIRC Home    About    Download    Register    News    Help

Print Thread
#174912 14/04/07 08:43 AM
Joined: Mar 2006
Posts: 19
H
hkr Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Mar 2006
Posts: 19
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)..

hkr #174914 14/04/07 09:22 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

hkr #174923 14/04/07 02:37 PM
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
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)

Last edited by Om3n; 14/04/07 02:40 PM.

"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
hkr #174924 14/04/07 02:37 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
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)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
hkr #174944 14/04/07 06:29 PM
Joined: Mar 2006
Posts: 19
H
hkr Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Mar 2006
Posts: 19
thxz, didn't think of /filter

hkr #174946 14/04/07 06:56 PM
Joined: Mar 2006
Posts: 19
H
hkr Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Mar 2006
Posts: 19
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.

Last edited by hkr; 14/04/07 07:12 PM.
hkr #174952 14/04/07 08:33 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2006
Posts: 19
H
hkr Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Mar 2006
Posts: 19
it actually might come in favour... on the second thought...


Link Copied to Clipboard