If it's not too much trouble, you would really be better off completely changing how you store your uptime information. Do not store it as words... "5 days, 3 minutes, 2 seconds". Instead, store is in $ctime format rather than using $duration or $date or $time.
Note that you should probably put the temporary join time data into a hash table, then when they leave, you can use that to check the difference with the time they left and see if the time is larger than what is stored in the text file.
Then, when they leave (part/quit), you write the difference of $ctime - original $ctime.
This method will allow you to easily use /filter to find the top times.
Your text file will look something like this:
After you use /filter to sort the data based on column 2, you can use $duration(time value) to get the time in weeks/months/etc. This will be very fast and easy and will not lag mIRC at all.
I'll consider writing up an example in a bit... though, you may want to try what I suggested on your own and see how far you can get.