From 4edccce9a39ec8a23d53fc15d37accba74468f66 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 1 Sep 2019 20:55:34 +0300 Subject: [PATCH] array: sort ints --- vlib/builtin/array.v | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 080f996434..fe58962fad 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -259,3 +259,17 @@ pub fn copy(dst, src []byte) int { } return 0 } + +fn compare_ints(a, b *int) int { + if a < b { + return -1 + } + if a > b { + return 1 + } + return 0 +} + +pub fn (a mut []int) sort() { + a.sort_with_compare(compare_ints) +}