mIRC Home    About    Download    Register    News    Help

Print Thread
#188749 29/10/07 10:54 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Hello smile

I have a list that can be 40 - 250 items long. Its the room list of the category. I save it in a hash table. I wrote an alias that will sort the rooms by user count, but now I want to sort them alphabetically.

I am looking into different ways of doing this. I am not opposed to sending info to a text file to sort.

I thought I could seperate each name by a comma and use $sorttok but 150+ tokens in one string? Doesnt sound like a good idea to me.

I'm looking for ideas on the best way to alphabetize this list.

$hget(list,0).item gives me the total number of items to alphabetize.

$hget(list,1).item would give me the first name in the list.


So how would you alphabetize it? Thank You!


Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
You could dump the items into a custom window, and sort them with /filter -ct 1 32 @win @win on them, where @win is your custom window.

Joined: May 2007
Posts: 89
T
Babel fish
Offline
Babel fish
T
Joined: May 2007
Posts: 89
If the purpose is to fill a nicklist in a @window, then you could just use the -S switch of the /window command.

Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Oh Sorry. Once Alphabetized rooms will be read from the hash table and put in a dialog list.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I suggest using filter, too (The numerical-sort-part could also benefit from using filter).
Add the data to a hidden window, sort it there, then filter it directly to your dialog ID (/filter -o).

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As mentioned, a dialog list can be sorted automatically with the "sort" option. Beyond that, /filter is the best way to sort a hash table.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I included "sort" in my list properties but it did nothing.

How does this work? I've never used sort in a dialog list.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It should sort alphabetically anything that is put into a list with the sort property on it.

Code:
dialog Sort {
  title "List Sort"
  size -1 -1 100 100
  option dbu

  list 1,5 5 80 80, sort
}

alias Sort {
  dialog -m Sort Sort
  did -a Sort 1 This
  did -a Sort 1 is
  did -a Sort 1 not
  did -a Sort 1 sorted
  did -a Sort 1 yet
}


You'll note that the text is sorted automatically in the list.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard