catala icon indicating copy to clipboard operation
catala copied to clipboard

Add a list sorting builtin to the language

Open denismerigoux opened this issue 1 year ago • 1 comments

This feature request comes from exchanges with the CNAF. Its use will be quite broad, and it justifies having this list sorting builtin in the Catala standard library that is implemented and maintained by us. Since it's polymorphic, it will probably require special syntax.

We looking at a function with signature : sort_list : 'a list -> ('a -> int) -> 'a list for elements that have a total order. The sort should be stable.

We may also have sort_list_partial : 'a list -> ('a -> 'a -> int) -> 'a list for elements with a partial ordering, though the need for this relaxed mode is less clear and it could be more confusing to lawyers.

denismerigoux avatar Jul 09 '24 08:07 denismerigoux

I will not claim that this is an appropriate solution, but this part of #715 seems worth mentioning: https://github.com/CatalaLang/catala/pull/715/files#diff-dbf6a0ad63bfdf74c44a0d71479400669f28e30f2e26a757191fc09745618026R68-R70

Non-polymorphic and quadratic, obviously.

AltGr avatar Oct 09 '24 15:10 AltGr