Why are you using ini files if they get "massive"? Didn't you know they are limited to something like 65535 lines (or KB, I forget which)? Variables are also extremely limited in length, so you might want to think of what happens after your "list" of comma-separated values reaches ~4096 bytes in length... Why not use hashtables? If you use hashtables for this, you could indeed see them in a similar way to an array, or even if you're clever, a linked list. Sort just like you would in any other language... Here's a common algorithm:
1. look for the lowest item within table x
2. add this item to the end of table y
3. remove this item from table x
4. jump back to 1 if there are any items left within table x
Here's an example... but before you copy and paste, keep in mind my reaction isn't going to be good if I find you've not learnt anything from this. It might give you an idea that stops you from relying on old, extremely limited implementations such as .ini files. I want you to read it, study it and learn it. That way I get the satisfaction of realising that I've helped someone to better themselves. If there is anything you don't understand, consult the /help file or feel free to ask here.
alias test_scores {
; make the Scores table
hmake Scores
; add values to the Scores hashtable
hadd Scores Steve 100
hadd Scores Bob 5
hadd Scores Tim 800
hadd Scores Cheeto 99
; save the Scores hashtable to a file
hsave Scores Scores.file
; load the Scores hashtable (as a temporary table)
hmake Scores_Temp
hload Scores_Temp Scores.file
; sort the Scores hashtable
hmake Scores_Sorted
var %item, %data, %index, %count = $hget(Scores_Temp,0).item
while (%count > 0) {
; step 1: get the lowest item
%item = $hget(Scores_Temp,%count).item
%data = $hget(Scores_Temp,%count).data
%index = 1
while (%index < %count) {
if ($hget(Scores_Temp,%index).data < %data) {
%item = $hget(Scores_Temp,%index).item
%data = $hget(Scores_Temp,%index).data
}
inc %index
}
; step 2: remove the item from the temp list
hdel Scores_Temp %item
; step 3: add the item to the sorted list
%index = sorted_ $+ $hget(Scores_Sorted,0).item
hadd Scores_Sorted %index %item
; step 4: back to the beginning
dec %count
}
; get rid of the temp table
hfree Scores_Temp
echo -a - printing the items out, in their sorted order:
%index = 0
%count = $hget(Scores_Sorted,0).item
while (%index < %count) {
var %tmp = $hget(Scores_Sorted,sorted_ $+ %index)
echo -a - %tmp has a score of $hget(Scores,%tmp)
inc %index
}
echo -a - printing the items out, in their reverse sorted order:
%index = $hget(Scores_Sorted,0).item
while (%index > 0) {
dec %index
var %tmp = $hget(Scores_Sorted,sorted_ $+ %index)
echo -a - %tmp has a score of $hget(Scores,%tmp)
}
; get rid of the sorted table
hfree Scores_Sorted
; get rid of the scores table
hfree Scores
}
edit: or use Horstl's suggestion, which is likely faster in this case but more specific to mIRC, so won't really benefit you for other programming languages.