in reply to Re: Data with Letter(s) & Number sort query
in thread Data with Letter(s) & Number sort query

Are you importing padded() from a module? I don't immediately see where that comes from.

Replies are listed 'Best First'.
Re^3: Data with Letter(s) & Number sort query
by Corion (Patriarch) on Nov 19, 2016 at 11:02 UTC

    No, padded is supposed to be implemented by merrymonk, as I understood it that they had the padding already but wanted to undo it after sorting.

      Sorry I gave the wrong impression. I added the 0 before numbers less than 1000 manually. I guess I could create such a function but it would be 'nice' to avoid that.

        Then something like the matching given by Laurent_R below and johngg as well are likely the best approach. Basically, you match your sort keys in the string, then pack or sprintf them into a (fixed-length) prefix to your string, let sort do its thing, and then remove the prefix again.

Re^3: Data with Letter(s) & Number sort query
by Laurent_R (Canon) on Nov 19, 2016 at 10:13 UTC
    Yes, same question to Corion, which is why I just added another complete solution below.