remove the original  method
@@ -180,34 +180,6 @@ $.assert(arr.sum() == 15)
(self) {
return self.reduce((acum, el) => acum + el)
},
- sort: #[desc("Returns a sorted version of the array.") example("
-arr = [5, 1, 5, 3, 2]
-$.assert(arr.sort() == [1, 2, 3, 5, 5])
- ")]
- (self) {
- // uses selection sort
- if self.all(item => item.type == @number) {
- min = (array, maxval = 999999999999) {
- let lowest = [maxval, 0]
- for i in 0..array.length {
- if array[i] < lowest[0] {
- lowest = [array[i], i]
- }
- }
- return lowest
- }
- let res = []
- let copy = self
- for i in self {
- i = min(copy)
- res.push(i[0])
- copy.remove(i[1])
- }
- return res
- } else {
- throw "Unsupported type in array " + self as @string
- }
- },
copy: #[desc("Returns a shallow copy of the array") example("
arr = [5, 6, 7]
assert(arr == arr.copy())
