aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-List.sorted.3
blob: 90cfc4b0fbc38b72894092338cb9a06f1351c77c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH List.sorted 3 2025-04-19T14:48:15.711933 "Tomo man-pages"
.SH NAME
List.sorted \- Creates a new list with elements sorted.

.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI List.sorted\ :\ func(list:\ [T],\ by\ =\ T.compare\ ->\ [T])
.fi

.SH DESCRIPTION
Creates a new list with elements sorted.


.TS
allbox;
lb lb lbx lb
l l l l.
Name	Type	Description	Default
list	[T]	The list to be sorted. 	-
by		The comparison function used to determine order. If not specified, the default comparison function for the item type will be used. 	T.compare
.TE
.SH RETURN
A new list with sorted elements.

.SH EXAMPLES
.EX
>> [40, 10, -30, 20].sorted()
= [-30, 10, 20, 40]

>> [40, 10, -30, 20].sorted(func(a,b:&Int): a.abs() <> b.abs())
= [10, 20, -30, 40]
.EE