Skip to content

Commit 5700ef7

Browse files
committed
sort_nums method added
PLEASE CHECK BEFORE MERGING
1 parent 2befaa4 commit 5700ef7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ class Helper {
123123
throw new TypeError("Input parameters not valid!");
124124
}
125125
}
126+
//To sort numeric arrays ascending and descending
127+
static sort_nums(arr, reverse = false) {
128+
this.is_array(arr);
129+
if (reverse) {
130+
return arr.sort(function(a, b){return b - a});
131+
} else {
132+
return arr.sort(function(a, b){return a - b});
133+
}
134+
}
126135
}
127136

128137
export default Helper;

0 commit comments

Comments
 (0)