roc icon indicating copy to clipboard operation
roc copied to clipboard

Implement `Sort` ability for ordering using a `compare` implementation

Open lukewilliamboswell opened this issue 1 year ago • 1 comments

Sort Ability

See zulip discussion thread for more information.

The Sort Ability defines the compare function, which can be used to compare two values for ordering.

Sort is not derived for Str as working with utf-8 strings which is a variable length encoding scheme is complex and is achived through a dedicated library such as roc-lang/unicode.

Definition of the Sort Ability.

# Sort.roc
Sort implements
    compare : a, a -> [LessThan, Equal, GreaterThan] where a implements Sort

lukewilliamboswell avatar Mar 04 '24 04:03 lukewilliamboswell

Follow-up note from Zulip: for the initial implementation, we should also have F32 and F64 not have the Sort ability (just like how they don't have Eq).

rtfeldman avatar Mar 04 '24 12:03 rtfeldman

I'm interested in taking a look at this. Can I pick it up?

jwoudenberg avatar Mar 30 '24 09:03 jwoudenberg

Absolutely! 😃

Happy to answer any questions you run into!

rtfeldman avatar Mar 30 '24 11:03 rtfeldman