If I'm reading your script the way you mean for it to be read, then your $2 should be $nick.

Anyhow, hash tables are a better solution than variables for such large amounts of data. You can then sort them through an hsave/filter/hget method. To see how to do that, use search on the forum and expand to about 2 years... look for posts by DaveC with the text "hash table sort" and you should find it. If not, just look for "sort" and DaveC as the poster.