in reply to Re^2: Refactor my sort
in thread Refactor my sort

Herkum:

My take on it is this: the comparison operator on a string is a bit slow since it has to take locale and such into account. The GRT basically packs the data into a string of bytes such that a simple numeric comparison would reliably sort the data.

This saves you time because rather than go through the locale-conversion code to order the strings each time they're accessed, you perform the conversion once (during pack), then you just treat the keys as integers X bytes long, which are much simpler to compare.

--roboticus

Replies are listed 'Best First'.
Re^4: Refactor my sort
by johngg (Canon) on Dec 22, 2006 at 23:10 UTC
    The GRT packs the data into a string, yes, but I'm pretty sure the sort is then lexical, not numeric. I believe that pack is the usual tool for creating the string but GrandFather did one here that used sprintf.

    Cheers,

    JohnGG