Javascript Challenge Sort Array without Built In Step By Step

  Рет қаралды 12,892

amil hasbala

amil hasbala

5 жыл бұрын

Pretty self explanatory. Its a step by step explanation on how to sort an array without built in sort function.

Пікірлер: 15
@a4ankit27
@a4ankit27 4 жыл бұрын
Seems like your final result is still not sorted . Is it ? [2,5,3,7,1....] ... how is this sorted ? And the reason for that is, you are putting your if swapped == 0 condition inside the for loop. You need to move that outside
@erickgeneric
@erickgeneric 2 жыл бұрын
DIdn't know I could vibe to a js sort tutorial
@mahermadany6030
@mahermadany6030 Жыл бұрын
Excellent code, simple bug that can be fixed easily
@aakashchauhan96
@aakashchauhan96 3 жыл бұрын
For better output use below code. function Sort(array) { var done = false; while (!done) { done = true; for (var i = 1; i < array.length; i++) { if (array[i - 1] > array[i]) { done = false; var tmp = array[i - 1]; array[i - 1] = array[i]; array[i] = tmp; } } } return array; } var numbers = [121,12, 10, 15,444, 11, 14, 13, 16,1]; Sort(numbers); console.log(numbers);
@shwethahv1684
@shwethahv1684 2 жыл бұрын
Such a complex code , why cant you use two i and j loop for (let i = 0; i < arr.length; i++) { for (j = i + 1; j < arr.length; j++) { if (arr[i] > arr[j]) { temp = arr[j]; arr[j] = arr[i]; arr[i] = temp } } }
@biswajitghosh3010
@biswajitghosh3010 Жыл бұрын
just becoz of time complexity its TC is O(n^2)
@hariharan5801
@hariharan5801 Жыл бұрын
But this gives ascending order na? 🙃
@thiernodem5681
@thiernodem5681 9 ай бұрын
@@hariharan5801 you just gotta reverse the greater than sign to less than, you will get descending order
@kushaldavda5892
@kushaldavda5892 2 жыл бұрын
This doesn't sory negative numbers in an array
@shwethahv1684
@shwethahv1684 2 жыл бұрын
Please dont confuse beginners, they might start hating to code
@jorasimg2233
@jorasimg2233 2 жыл бұрын
I am at beginner level, can you paste a complete code here.
@lv10chiju19
@lv10chiju19 Жыл бұрын
I dont care how you code but the output is not true
@shakeelahmed-wv8oh
@shakeelahmed-wv8oh 2 жыл бұрын
Dont code 💩
@batboy143
@batboy143 2 ай бұрын
really bad code
Learn JavaScript SORTING in 6 minutes! 🗃
6:42
Bro Code
Рет қаралды 19 М.
How to randomly sort an array? | LeetCode task | JavaScript
10:20
Front-end Science із Сергієм Пузанковим
Рет қаралды 12 М.
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 4,8 МЛН
UNO!
00:18
БРУНО
Рет қаралды 2,3 МЛН
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
JavaScript Comparator Function | Sorting Explained!
12:21
The Code Creative
Рет қаралды 32 М.
Sort an integer array using single for loop [Java]
18:29
Coding Env
Рет қаралды 18 М.
JavaScript Problem: Sorting an Array of Objects
9:25
All Things JavaScript, LLC
Рет қаралды 54 М.
JavaScript Array Sort Method Practice in 5 Minutes
7:13
James Q Quick
Рет қаралды 35 М.
Алгоритм сортировки пузырьком! ПОЛНОЕ РУКОВОДСТВО! ✅ JavaScript
16:26
Обучение HTML, CSS, JavaScript | Анатолий Ивашов
Рет қаралды 1,4 М.
16.9: Array Functions: sort() - Topics of JavaScript/ES6
9:19
The Coding Train
Рет қаралды 165 М.
How to MASTER Javascript FAST in 2023
12:49
Internet Made Coder
Рет қаралды 349 М.
sort Array Method | JavaScript Tutorial
5:47
Florin Pop
Рет қаралды 138 М.
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 4,8 МЛН