mathematica: fix sort predicate stability

Incorrect sorting predicate was found as part of
https://github.com/NixOS/nix/issues/12106 where `nix` was crashing on
the code like:

    $ nix eval --expr 'builtins.sort (a: b: true) [ 1 2 3 ]'
    ...
    Aborted (core dumped)

Note: the crash happens here because sorting predicate does not
implement `lessThan` and triggers assertion failures for
`std::stable_sort` that backs `builtins.sort`.

The change restores `lessThan` semantic for version sorting.
This commit is contained in:
Sergei Trofimovich
2024-12-26 23:09:36 +00:00
parent 9ceb1173fb
commit bf740322a7
@@ -30,7 +30,7 @@
let
versions = callPackage ./versions.nix { };
matching-versions = lib.sort (v1: v2: lib.versionAtLeast v1.version v2.version) (
matching-versions = lib.sort (v1: v2: lib.versionOlder v2.version v1.version) (
lib.filter (
v: v.lang == lang && (version == null || isMatching v.version version) && matchesDoc v
) versions