Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Challenge: sort weekdays in week-order (elegantly and efficiently)

by LanX (Saint)
on Jul 26, 2022 at 16:06 UTC ( [id://11145759]=note: print w/replies, xml ) Need Help??


in reply to Re: Challenge: sort weekdays in week-order (elegantly and efficiently)
in thread Challenge: sort weekdays in week-order (elegantly and efficiently)

I have trouble finding a canonical explanation of Orcish Manoeuvre, but isn't Memoize faster in this case?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Challenge: sort weekdays in week-order (elegantly and efficiently)
by kcott (Archbishop) on Jul 26, 2022 at 19:59 UTC

    G'day Rolf,

    "I have trouble finding a canonical explanation of Orcish Manoeuvre, ..."

    "A Fresh Look at Efficient Perl Sorting" describes many sorting techniques. The section on OM points to a footnote with details of a book by the inventor of this algorithm. I don't own, nor have I read, this book, so I can't comment further.

    "... but isn't Memoize faster in this case?"

    Try Benchmark to answer that. Please post your results: I, and no doubt others, would be interested.

    — Ken

Re^3: Challenge: sort weekdays in week-order (elegantly and efficiently)
by ikegami (Patriarch) on Jul 26, 2022 at 16:46 UTC

    OM is basically ST, but where the sort is provided the default comparison function ($a cmp $b).

    Technically, any of the four builtin compare functions would work equally fast.

    • $a cmp $b
    • $b cmp $a
    • $a <=> $b
    • $b <=> $a
Re^3: Challenge: sort weekdays in week-order (elegantly and efficiently)
by hippo (Bishop) on Jul 26, 2022 at 17:02 UTC
Re^3: Challenge: sort weekdays in week-order (elegantly and efficiently)
by eyepopslikeamosquito (Archbishop) on Jul 27, 2022 at 07:06 UTC
      Thanks.

      From my perspective: "Orcish" is just the inner workings of a sort based on a key-function, like in Sort::Key °

      AFAIK is sorting by key functions the default in Python.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      °) Tho Salva wasn't explict if the result of a key-function is cached in his implementation.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145759]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-28 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found