aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-List.sort.3
blob: fa35952b92cc9ef03667f8b40f0a8c15a05b8905 (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
39
40
41
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH List.sort 3 2025-04-21 "Tomo man-pages"
.SH NAME
List.sort \- sort a list
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI List.sort\ :\ func(list:\ @[T],\ by\ =\ T.compare\ ->\ Void)
.fi
.SH DESCRIPTION
Sorts the elements of the list in place in ascending order (small to large).


.SH ARGUMENTS

.TS
allbox;
lb lb lbx lb
l l l l.
Name	Type	Description	Default
list	@[T]	The mutable reference to 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
Nothing.

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

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