# MiniZinc Documentation - Standard Library

Functions and Predicates
function array [int] of $$E: arg_sort(array [$$E] of int: x) =
sort_by([ i | i in index_set(x) ], x)
(standard decomposition from builtins.mzn:1018)

Returns the permutation p which causes x to be in sorted order hence x[p[i]] <= x[p[i+1]].

The permutation is the stable sort hence x[p[i]] = x[p[i+1]] $$\rightarrow$$ p[i] < p[i+1].

function array [int] of $$E: arg_sort(array [$$E] of float: x) =
sort_by([ i | i in index_set(x) ], x)
(standard decomposition from builtins.mzn:1027)

Returns the permutation p which causes x to be in sorted order hence x[p[i]] <= x[p[i+1]].

The permutation is the stable sort hence x[p[i]] = x[p[i+1]] $$\rightarrow$$ p[i] < p[i+1].

function array [$$E] of int: sort(array [$$E] of int: x)

Return values from array x sorted in non-decreasing order

function array [$$E] of float: sort(array [$$E] of float: x)

Return values from array x sorted in non-decreasing order

function array [$$E] of bool: sort(array [$$E] of bool: x)

Return values from array x sorted in non-decreasing order

function array [$$E] of var opt T: sort_by(array [$$E] of var opt $T: x, array [$$E] of int: y) Return array x sorted by the values in y in non-decreasing order The sort is stable, i.e. if y[i] = y[j] with i < j, then x[i] will appear in the output before x[j]. function array [$$E] of var$T: sort_by(array [$$E] of var T: x, array [$$E] of int: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y[i] = y[j] with i < j, then x[i] will appear in the output before x[j].

function array [$$E] of T: sort_by(array [$$E] of $T: x, array [$$E] of int: y) Return array x sorted by the values in y in non-decreasing order The sort is stable, i.e. if y[i] = y[j] with i < j, then x[i] will appear in the output before x[j]. function array [$$E] of var opt$T: sort_by(array [$$E] of var opt T: x, array [$$E] of float: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y[i] = y[j] with i < j, then x[i] will appear in the output before x[j].

function array [$$E] of var T: sort_by(array [$$E] of var $T: x, array [$$E] of float: y) Return array x sorted by the values in y in non-decreasing order The sort is stable, i.e. if y[i] = y[j] with i < j, then x[i] will appear in the output before x[j]. function array [$$E] of$T: sort_by(array [$$E] of T: x, array [$$E] of float: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y[i] = y[j] with i < j, then x[i] will appear in the output before x[j].