sort Array Method | JavaScript Tutorial

preview_player
Показать описание

In this tutorial, we're going to learn about the #sort #JavaScript #Array Method and how it can be used to sort an array of items.
We're also learning why the sort method doesn't work by default on an array of numbers and how we can fix that.

---
Follow me on:
Рекомендации по теме
Комментарии
Автор

Thank you a lot, I was stuck for like 7 hours trying to swap every array in the list. This method is so much simple and cool

RafaelSales
Автор

simple, short, and very clean explanation I was looking for! thanks!

clarinetisfying
Автор

Super helpful tutorial. I was trying to sort arrays of numbers and couldn't figure out why it wasn't working as expected and what exactly happened when you told sort to use 'a-b'.

You gave me all the info I needed. Thank you!

kevinbegin
Автор

This is amazing florin. I follow you on twitter but this is the first time I came here. I finally understand this function

tammybatubo
Автор

Man, I thank god that I found you, thanks for tutorial, you saved me a lot of time. Love you man !

AG-qpgn
Автор

Can you please explain why a comes first when it returns positive value...that's the confusion I have☹️

saravanan.r
Автор

Explanation was short and sweet . Frankly speaking, I got the main point .

moududahammed
Автор

Finally understood. Read shit loads of blogs but nowhere was that greater and smaller condition mentioned properly, all of them just stated condition.

alanwalker
Автор

dude i have no words like what... you have no idea the wierd explanations I saw for this and you made it so easy. thank you

A_Saban
Автор

if(array.length > 2) a = current; b = next;

.sort() method is looping over the array

I hope you gets it, this is the simplest way I could explain it

negativepunk
Автор

Thank you so much. I was stuck on this sort() method. You made things easy.

Debjit_Adhikari
Автор

Hi @florin pop. I am no clear about the compare function you put inside sort method. How the comparing is done to sort all numbers because the compare function has a and b which are two parameters? Does sort method take number at index 0 and compare to at index 1, etc?

muadzrosli
Автор

Thank you for showing descening and ascending fantastic video

ivangelinelol
Автор

javascript is prety cool. Also, thanks for the explanation, very clear and concise.

joaopedroalves
Автор

I was stuck in this thing. This really cleared things up.

gideonilm
Автор

Thanks, I was unsure about how things "came first" until I came across this video.

ThrashDawg
Автор

great video and a good explanation for self-learner. too much appreciated.

haruNL
Автор

Now, I understand what sort is used for arrays. Thanks!

itsamazing
Автор

Thank you for making the video it helped me a lot while i was confused.

smridhisingh
Автор

Thank you so much for the clear explanation!

darkopesevski