in reply to Re: having trouble with a schwartzian transform
in thread having trouble with a schwartzian transform

I don't really see how an Orcish manoeuvre would improve a Schwartzian Transform sort.
  • Comment on Re^2: having trouble with a schwartzian transform

Replies are listed 'Best First'.
Re: having trouble with a schwartzian transform
by jonadab (Parson) on Oct 14, 2014 at 10:57 UTC

    In this particular case, I'm not sure it would. In general, it can, in situations where the (chronologically) first transform consumes a lot of time for some reason, if you have duplicated data in the list that you are sorting. Not needing to perform the same time-intensive computation repeatedly saves time. But in this case, it doesn't look like there are going to be a lot of duplicate data (though only someone with access to the original poster's real data could say that for sure), and furthermore that regular expression in the first transform doesn't look like it would be much of a bottleneck, so I'm not sure much if anything would be gained.

Re^3: having trouble with a schwartzian transform
by Ea (Chaplain) on Oct 14, 2014 at 13:45 UTC
    You're right, Laurent. You only calculate the sort value once in the first call to map, so there's no savings to be made by caching.

    Those two techniques must be stored together in the "neat things to use with sort" area of my brain. Apologies.

    Sometimes I can think of 6 impossible LDAP attributes before breakfast.