Custom Array Sorts in JavaScript

preview_player
Показать описание
This video discusses how you can run sorts on Arrays of Numbers or Arrays of Objects to get the proper results.
We can create our own custom sort function to handle non-string sorts.

See Also: This tutorial on the JavaScript International Object's string compare method for dealing with multilingual sorts.
Рекомендации по теме
Комментарии
Автор

The precise way in which you articulate this explanation is such a breath of fresh air, especially given the treacherousness of the sea of poorly-worded explanation/tutorial videos on YouTube. Subbed.

robbyrish
Автор

Fantastic explanation and examples. One thing I might add: the positive (1) result indicates a change in order is needed. The negative (-1) or zero result means no change needed. What I have come to understand is that sort() loops over the array, applying the comparison to each consecutive pair of elements for as many iterations are needed until no changes are needed (all comparisons of consecutive pairs produces a negative result).

eruston
Автор

The absolute best explanation of custom sort I've seen on Y.T. or the internet in general.

Colstonewall
Автор

I know that I am watching this awesome explanation after 2 years, but Kudos to you and Thank you .

prabhupadsahu
Автор

Best video I found so far explaining this concept. I couldn't grasp how it could sort from low to high numbers at first but now I understand it runs the entire array multiple times until all the values have been compared and put in order.

creativestarfox
Автор

Subscribed. This was phenomenal. By far the clearest, most concise explanation of how to do this anywhere on the internets. Keep it up!

McShiggley
Автор

well done, my new javascript textbook flew right over this like it was common knowledge. Thank you.

chriscarlsonofficial
Автор

Literally the best explanation for sort. Really. Noone on youtube mentions that it goes through the number list until its fully has it sorted and by using its own sorting method behind the scenes. Thanks for the 100th time Steve, you da man.

drakecoleman
Автор

sir thank you your explination much better than my teacher

omare
Автор

This is the best sort() explanation I have found! Excellent

theriddler
Автор

Finally after hours of finding just bad or wrong explanations, thanks a lot!

hugovallezinzun
Автор

Best explanation of sort method, ever! :)

formickaw
Автор

Though there's one more way that is a lot simpler but this guy is a lot more explained/clear! I really like this guy, he's the best!

KeepLearing
Автор

This Voice man... i want Steve's voice to narrate my life...

mitrasu
Автор

Explanation is really handy. Thanks man.

TechnoDB
Автор

THIS. IS. SO. AWESOOOOME... Thanks Steve. The knowledge of this alone has added a lot to my JS skill.

emiklad
Автор

You are all we need to know if we want to excel in javascsript.

rotrose
Автор

some good movies you got in that array there. oh, and great explanation as well

gregorio
Автор

Great explanation of sort, well done!

tonygriffin
Автор

Dude I subscribed and going to share your videos please don't let me down keep up the good work

jamilamini
welcome to shbcf.ru