Javascript Tutorial 21 - How to sort arrays

preview_player
Показать описание
Here we look at sorting our arrays. We sort them in an alphabetical fashion, ascending numerically and descending numerically.

Рекомендации по теме
Комментарии
Автор

Thank you a ton! Been to two courses and although they showed numerical sorting with a-b you're the only guy who actually explained what it was for and how it worked.

miklerosswell
Автор

Well done sir. Thanks for the concise, clear, and informative video.

awc
Автор

this really helped i was in a challenge to make a sorting program whoever won got 5 dollars (not much but it was fun)

waporwave
Автор

awsome video, still trying to wrap my head around this one.

DEdesigns
Автор

I assume youre talking about the sorting array numerically. It was hard for me before too. In the end theres not much to think about, the sort method was designed to take a comparison function as an argument and the interpreter will execute it in its own way. But you can think of the function being running on all the array elements going from left to right, over and over again until its done. Anytime a - b returns a positive number the first operand (a) goes to the right, b goes to the left

AnthonyVipond
Автор

I dont get it, how many times sort function compare a and b? If it goes 1 time the output array will look like something like this: [35, -55, 5, 112, 4, -5, -123, 123];
Or does it have some kind of loop?

Levelord
Автор

TY, TY...
Seven minutes to explain it??? I took 7 minutes searching this video. |||| And I don't speak english, dude.
TY again.

Brunonms