This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Sorting chanlist like mIRC

Old posts that have not been replied to for several years.
Locked
P
ProXy
Op
Posts: 126
Joined: Sun Aug 11, 2002 3:09 pm

Sorting chanlist like mIRC

Post by ProXy »

I want to write a script that sorts the chanlist like mirc does. The Problem is, that if i sort with -ascii, the its case sensitive. When i use -dictionary some brackets are in a wrong postiton, for example. mirc has the Pipe at the end, and [ or ] right before the pipes. With -dictionary the brackets are before all chars...

Is there a way to make the list like mIRC does...?
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

you have to add all the users to three different lists (assuming the server doesn't support % halfop, if it does you'll have to make four lists ;) ) one for oped, one for voiced and one for normal users, then you simply do lsort -increasing $list on it. Finally you join the lists into one with op's on top, then voice, then normal users...
Elen sila lúmenn' omentielvo
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The lsort command support the -command option.

You would need to create a command to attach to this, to sort as you wish.
P
ProXy
Op
Posts: 126
Joined: Sun Aug 11, 2002 3:09 pm

Post by ProXy »

-increasing also doesnt work, because capital letters where above lowercase letters. The Problem with OP and VOICE is no difficulty, the only problem is to get a list, equal to the mIRC list.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

[lsort -increasing -dictionary $somelist]
Elen sila lúmenn' omentielvo
P
ProXy
Op
Posts: 126
Joined: Sun Aug 11, 2002 3:09 pm

Post by ProXy »

This still doesnt fix the problem: I have a user called ][CBS][Merlin. This user is still reported before all other users. In the mIRC-List he is below all normal letters, but in front of Pipes...
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Well, after the list is sorted, you simply need to rearrange those sections of nicks. Something like:

Code: Select all

set brackets [list]
set pipes [list]
set normal [list]
foreach nick $nicklist {
  set fc [string index $nick 0]
  if {$fc == {[} || $fc == {]}} {
    lappend brackets $nick
  } elseif {$fc == "|"} {
    lappend pipes $nick
  } else {
    lappend normal $nick
  }
}
set nicklist [concat $normal $brackets $pipes]
(not tested)
P
ProXy
Op
Posts: 126
Joined: Sun Aug 11, 2002 3:09 pm

Post by ProXy »

Thx, I will try this script tomorrow :)
P
ProXy
Op
Posts: 126
Joined: Sun Aug 11, 2002 3:09 pm

Post by ProXy »

Well this script only would work if the second letters are NOT any of the special chars. So, I prefer using ASCII - the one error isn`t so bad - it would be much too difficult, to manage these right...
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

why dont you convert all nicks to lower-case before sorting them?
P
ProXy
Op
Posts: 126
Joined: Sun Aug 11, 2002 3:09 pm

Post by ProXy »

Because for some user - like me - it is important to have so capital letters in their nicks. So I prefer -dictionary, there I only have some problems with brackets...
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

hm... don't know if this is possible in tcl, but i thought, you put the nicks in a second list and sort the nicks in the second list in lower-case. and then with that list, you sort the original list (with capital letters).
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Hey I just had another idea. Why not convert the brackets and pipes to some invalid nick chars, that are higher than 'z'. For instance, ascii code 250, 251, 252.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Well put stdragon, not even I thought of that. Twice I have attempted to create a filter commands, but been unsucessful. However, conversion (using string maps), should make the whole process easier, without having to convert before and after the sort, the mapping can take place on the fly using lsorts external sorter abilities.

Code: Select all

proc mircsort {list} {
  return [lsort -command mircsortproc $list]
}

proc mircsortproc {f s} {
  set map [list \[ \250 \] \251 \| \252]
  set f [string map $map $f]
  set s [string map $map $s]
  return [string compare $f $s]
}
Use "mircsort" instead of lsort, and you should get a correct list back.

You only need to tweak and add to the mapping list, should any sorting changes be needed.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Well put stdragon, not even I thought of that.
That's why I'm the Revered One, and you're... well, the Revered One.
Locked