FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Algorithm-in-JavaScript/Sort/setSort/setSort.js at master · kundan594/Algorithm-in-JavaScript · GitHub
kundan594
/
Algorithm-in-JavaScript
Public
forked from
rohan-paul/Algorithm-in-JavaScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Algorithm-in-JavaScript
/
Sort
/
setSort
/
setSort.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
21 lines (15 loc) · 566 Bytes
Breadcrumbs
Algorithm-in-JavaScript
/
Sort
/
setSort
/
setSort.js
Copy path
File metadata and controls
executable file
·
21 lines (15 loc) · 566 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
setSort_1000
=
arr
=>
{
let
newArr
=
new
Array
(
1000
)
.
fill
(
0
)
let
sortedArr
=
[
]
;
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
newArr
[
arr
[
i
]
]
=
1
// this 1 can be any other arbitrary number. Becuase its just a hook with which I will get the key in the next step
}
for
(
let
i
=
0
;
i
<
newArr
.
length
;
i
++
)
{
if
(
1
===
newArr
[
i
]
)
{
sortedArr
.
push
(
i
)
}
}
return
sortedArr
;
}
let
myArr
=
[
34
,
203
,
3
,
746
,
200
,
984
,
198
,
764
]
;
console
.
log
(
setSort_1000
(
myArr
)
)
;
// => [ 3, 34, 198, 200, 203, 746, 764, 984 ]
Back
|
FazBrowse Home
|
New Git URL