-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsortArray.js
More file actions
38 lines (33 loc) · 922 Bytes
/
Copy pathsortArray.js
File metadata and controls
38 lines (33 loc) · 922 Bytes
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
function myFunction(){
const fruits=['orange','banana','apple',"guavava"];
a=fruits.sort();
return a;
}
function myFunction1(){
const fruits=['orange','banana','apple',"guavava"];
a=fruits.reverse();
return a;
}
function myFunction2(){
const points=['40','101','1','5','25','10'];
a=points.sort();
return a;
}
function myFunction3()
{
const points=['40','101','1','5','25','10'];
a=points.sort(function(a, b){return a - b}); //better mathod for sorting in accending order
return a;
}
function myFunction4()
{
const points=['23','40','10','0','55','22']
a=points.sort(function(a, b){return b - a}); //better mathod for sorting in decending order
return a;
}
function myFunction5()
{
const points=['23','40','10','0','55','22']
a=points.sort(function(a, b){return 0.5 - Math.random()}); // sorting in random order
return a;
}