Skip to content

Commit 3351b78

Browse files
committed
sort
1 parent c6651db commit 3351b78

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,25 @@ console.log(number1); // [ 33, 534, 24, 222,336, 553, 2178, 76,89, 90,
259259

260260
### Sorting of an array.
261261

262+
#### 0-9 / string you may easily sort.but more number like 10 to unlimited then you can't sort easily.You need to code differently.
263+
262264
```javascript
265+
// easy way:
266+
const arr1 = [6, 9, 8, 1, 2, 5, 3, 7, 4, 0];
267+
console.log(arr1.sort()); //[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
268+
269+
const arr2 = ["kabir", "jarim", "kikur", "ayara", "bib"];
270+
console.log(arr2.sort()); //[ 'ayara', 'bib', 'jarim', 'kabir', 'kikur' ]
271+
```
263272

273+
- different way of sort.
274+
275+
```javascript
276+
const arr3 = [22, 53, 767, 234, 43, 15, 75, 89];
277+
arr3.sort(function (a, b) {
278+
return a - b;
279+
});
280+
console.log(arr3); //[15, 22, 43, 53,75, 89, 234, 767]
264281
```
265282

266283
### Arguments:

array-sort.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const arr1 = [6,9,8,1,2,5,3,7,4,0]
22
// console.log(arr1.sort());
33
const arr2 = ['kabir','jarim','kikur','ayara','bib']
4-
console.log(arr2.sort());
4+
// console.log(arr2.sort());
55

66

77
const arr3 =[22,53,767,234,43,15,75,89];
88
arr3.sort(function(a,b){
99
return a-b;
1010
})
11-
console.log(arr3);
11+
console.log(arr3);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy