{
"id": "fn-array-sortWith",
"dataComponent": "array",
"heading": {
"title": "sortWith",
"badges": ["Array", "PARTIAL"]
},
"synopsis": "Sorts an array using a comparator function. Partial usage supported.",
"codeBlocks": [
"extend(\"array\")\n\nnums = [3,1,2]\nsput(array:sortWith((a,b) => b - a, nums))\n// => [3,2,1]\n\n# Partial usage:\ndescSort = array:sortWith((a,b)=>b-a)\nsput(descSort([2,3,1]))\n// => [3,2,1]"
],
"notes": [
"Takes a comparator function (a,b) => number, and array.",
"Returns a sorted copy.",
"Partial usage supported."
]
}