not only did I fully learn and understand the logic behind the comparator function, but I also found myself starting to relax and peacefully enjoy learning it just by the cadence and tone of your voice. Thank you! Just subscribed
Thank You So Much. I've been flipping through hours of videos and documentations but still struggle to understand what the comparator function do. Your video definitely makes things clearer especially when you wrote out the if statements and have them return -1, 1, and 0. Everything just clicked.
I was stuck with the problem of writing a custom sort for my nested array and when I found the MDN docs for the topic I couldn't understand the logic behind returning 1, -1 & 0. But sir you explained so well and really saved me & made my day, I can't thank you enough.
I finally understood the sort method and comparator function but what I don't understand is how come this guy only has around 8K subscribers!?? Given the quality of the content, imo he should have atleast half a million subs
Thank you so much. a) Very organized explanation and easy to understand. b) Soothing voice in the midst of this confusion called learning. c) Liked and subscribed. Thanks again,
I wanted to thank you for the video, I could understand better the a-b logic, and I also had some fun while learning. Keep posting videos like this, means a lot for some of us, even when English is not our first language, we learn a lot.Thanks again.
Im pretty sure you could teach an Ant to become an austronaut, but for real, i wasn't understanding it clearly but you made it simple for me, thank you!
i encourage you to do more tutorial , i never have i ever commented on some tutorial videos this was the first one the way that you explain is was so good ,keep doing it
Bro you deserve million of subscribers. I watched a lot of videos before i finally found this masterpiece. Thank you so much it really helped a lot. Hope our professors would teach the way you do.
Wow you are very good! Probably the best in explaining the comparator function. So far, you might be the only one who show the respective utf code, and also be comprehensive enough to show for alphabets and numbers. Liked plus Subscribed!
Thank you. I like to learn how and why something is the way it is. I intend to reverse engineer the sort method myself to fully understand and appreciate the method. I think I can do it by using nested for loops and conditional logic.
That was just too good. Thank you so much for such a lucid explanation. Keep contributing your knowledge. There are very few people out there who can teach concepts in such detail.
Thank you so much for your excellent explanation. Now I really do understand the logic behind those dubious comparator functions after having read it in a book. Great video! I subscribed right away
The first iteration a is going to take the value of the second item in the array and b is going to take the first item of the array. [5, 2] comparatorFunction(a, b) // a = 2 and b = 5
really really thanks a lot🙏🙏 this makes all clear for me about sort method thanks to you🙏 i really appreciate your efforts sir🙏 thank you so much this is really appreciable🌸✨ thank you once again for saving me✨
a tiny correction, in the comparator function, the first argument(a) is actually the second value of a pair of adjacent values being compared. So in the case of [2, 5, 100, 4], on the first iteration, a is 5 and b is 2. It's a little counter intuitive but in that case, a < b means 5 < 2. If true, we return a negative number, which means a should be before b, that is 5 should be before 2. (This is false) Else if a > b i.e., 5 > 2, we return positive number, which means b should be before a, that is 2 should be before 5. (This is true)
Hi, thanks for the very clear explanation, it's the first video I see which explains it in depth to this extent. There's just something which I was wondering about the comparator function : how exactly does it do the comparison between the different elements in the array? What exactly is happening behind the scenes? Some special kind of algorithm is implemented to compare the elements in a certain order? (is the first element compared to all the other elements of the array, then the second to all the others until the end, etc. or something else?) Hopefully my question makes sense.
if I have 2 numbers in array [ 2, 5] And I use .sort(...) with comparable fn, and I just console log a and b....5 will show as a, and 2 as b....why is that?
What I don' t understand is how the values are taken after the first operation? For example , in the video , in the first step a is 2 and b is 5 so 2 is sorted before 5. However, after that which value is taken as a and b? Is it 2 and 100 or 5 and 100? I am confused. Can someone please explain the step wise process of this sort operation?
🎓 New Course Available! "Scrollytelling 101": store.thecodecreative.com/scrollytelling
not only did I fully learn and understand the logic behind the comparator function, but I also found myself starting to relax and peacefully enjoy learning it just by the cadence and tone of your voice. Thank you! Just subscribed
Excellent! Thanks for subscribing Roman!
1000% percent. He's such a natural.
really hits the spot in my ADHD brain! glad I found this video. now I understand the comparator function much better!
That's great to hear Mondir. 👍🏻 Thanks for watching!
couldn't' agree more!
holy smokes. the most thorough video on a comparator function ever. this made it really click for me. amazing walk-through and explanation.
Great to hear, thanks for watching!
finally someone explained this in such an easy manner.💕
Glad to hear!
you have no idea how much content i've watched until finding this video that made everything so clear for me! thanks a lot, Gregg!
Glad it helped!
I have 4 best-rating courses on Udemy, but this teacher is THE BEST.
Thank you for watching!
underrated ytber , only vid on yt who perfectly explains the sorting method hats off bro ,
I appreciate that!
Amazing! Showing the reason why it is sorting the way it sorting was the best part!
Thank you!
Glad you enjoyed it!
why this video has so few views? he literally explained it in a way I'll never forget my entire life!
Thank you, glad it was helpful!
i love how thorough you were. i watched it twice and now i can see so many ways that this will be useful.
Excellent, thanks for watching!
Thank You So Much. I've been flipping through hours of videos and documentations but still struggle to understand what the comparator function do. Your video definitely makes things clearer especially when you wrote out the if statements and have them return -1, 1, and 0. Everything just clicked.
Glad it helped!
for a channel that teaches this well it deserves more subs👍
Thank you so much 😀
I was stuck with the problem of writing a custom sort for my nested array and when I found the MDN docs for the topic I couldn't understand the logic behind returning 1, -1 & 0. But sir you explained so well and really saved me & made my day, I can't thank you enough.
Thanks for watching. More to come!
I finally understood the sort method and comparator function but what I don't understand is how come this guy only has around 8K subscribers!?? Given the quality of the content, imo he should have atleast half a million subs
Thank you, working on it! :-) Happy New Year!
Thank you so much.
a) Very organized explanation and easy to understand.
b) Soothing voice in the midst of this confusion called learning.
c) Liked and subscribed.
Thanks again,
Great to hear, thanks for watching!
Finally, I understood the logic behind this "compareFunction" callback function. Thanks a lot.
👍🏻👍🏻👍🏻
Wow!!! finally i understand this sorting topic in an easier way. The analogy in this video will help even a slow learners thanks
Glad it was helpful!
Finally I understand Array Sorting. Thank you very much
Glad it helped!
Thanks my man! I'd been searching for a clear, straightforward, and hands-on explanation to no avail. That's until I got to your video. Great work!
Great, glad it was helpful!
To subscribe to the channel: ruclips.net/channel/UCmOpHGj4JRWCdXhllVTZCVw
thank you for explaining this in depth. Other people were just repeating what was written in w3schools website.
Great, thanks for watching!
Thank you so much!!! This is one of the best explanation videos that I ever have seen about this topic.
Glad it was helpful!
Thanks to this video I could do exercise number 8 of Jonas Schmedtmann's coding challenge about array methods! Thank you so much, nice voice btw!
You're very welcome!
Really clear explanation. Love how you explain return logic and the charCodeAt logic. Thanks
Glad you liked it
I was so confused before, thank you so much to explain this in such a simple and easier way.
Great to hear!
Join "The Code Creative Community" group on Facebook: facebook.com/groups/thecodecreative
Wow! This video is amazing. I was trying to understand this function and how it works, and with your tips now I understood! Thankyou
Glad it was helpful to you Levi. Thanks for watching!
I wanted to thank you for the video, I could understand better the a-b logic, and I also had some fun while learning. Keep posting videos like this, means a lot for some of us, even when English is not our first language, we learn a lot.Thanks again.
That's great to hear. Thanks Ezequiel!
the only good video on basic sort so far
Glad it was helpful!
Hands down the best explanation, Thank you very much!
Glad it was helpful!
Sir, your way of explaining is too good, 💎
Thanks Robin!
Im pretty sure you could teach an Ant to become an austronaut, but for real, i wasn't understanding it clearly but you made it simple for me, thank you!
Glad I could help!
i wasnt sure how the -1 and 0 and 1 affect the returned result.. thanks for claryfing things up !
Awesome!
Finally! What a clear explanation, thank u!! I would love if you make a video explaining what return is :)
Do you mean "return" as in a return statement within a function?
@@TheCodeCreative Yup, return statement within a function
📖 Download my FREE "Google Search Secrets for Developers" Cheat Sheet:
store.thecodecreative.com/google-secrets-cheat-sheet
I think I finally found the perfect pace and instructor….
Perfect! Thanks Dominik!
Thanks!!, this was breaking my head. Greetings from Colombia.
Great, thanks for watching!
thank u! your channel is underrated
Thank you!
Explained it a lot clearer than other tutorials. You just earned another subscriber!
Awesome, thank you!
i encourage you to do more tutorial , i never have i ever commented on some tutorial videos this was the first one the way that you explain is was so good ,keep doing it
Great to hear, thanks for watching!
Literally Perfect ! Just Perfect ! 😘
Thank you so much!!
Sir you are God sent! Thank you so much! It make perfect sense now.
Great! 👊🏻👍🏻
Bro you deserve million of subscribers. I watched a lot of videos before i finally found this masterpiece. Thank you so much it really helped a lot. Hope our professors would teach the way you do.
Thank you so much 😀 It's encouraging to know that the videos are helpful. 👍🏻
The best explanation ever.
Glad to hear! Thanks for watching 👍🏻
thank you sir for the beautiful explanation. You really deserve a lot more subs
Thank you too
Wow you are very good! Probably the best in explaining the comparator function.
So far, you might be the only one who show the respective utf code, and also be comprehensive enough to show for alphabets and numbers.
Liked plus Subscribed!
Great, thank you! Glad it was helpful 👍🏻
Thank you. I like to learn how and why something is the way it is. I intend to reverse engineer the sort method myself to fully understand and appreciate the method. I think I can do it by using nested for loops and conditional logic.
Right on!
Thanks for your explanation make me understand about sort function javascript👍
Excellent! Any other topics you'd like to see a video on?
That was just too good. Thank you so much for such a lucid explanation. Keep contributing your knowledge. There are very few people out there who can teach concepts in such detail.
Great, thanks! Glad it was helpful!
@@TheCodeCreative It was indeed very helpful. Thanks again.
Thank you for this video . Just loved how you thoroughly explained everything . looking forward to learning more topics with you
Hey Mitch! Thanks for the comment. More videos coming soon 👍🏻
Thanks! you explained this so clearly and thoroughly. Well done good sir.
Glad to hear, thanks for watching!
Thank you so much for your excellent explanation. Now I really do understand the logic behind those dubious comparator functions after having read it in a book. Great video! I subscribed right away
Excellent!
Finally I could understand, thanks!
Glad it helped!
you are the best explainer thank you so much
Thank you!
Great video! I am clearer on this topic now.
Excellent!
Superb explanation , with meaningful insights!!!
Great to hear, thanks for watching!
great explanation that I have ever seen, thank you
Glad you enjoyed it!
Spectacular explanation! really appreciate it, thxz man
Glad you liked it!
Clearly explained.Thank you
Glad it helped! Feel free to join the Facebook group: facebook.com/groups/thecodecreative
Woow Thank Budy !!! Finally i understand a-b or b-a
Thank You So Much Brother
Keep It Up
That's great to hear, thanks for watching!
Wow! You made that easy to understand for me. SUBSCRIBED
awesome, thanks!
Simple and concise. Thanks for the vid man!
Great, thanks for watching!
Very nice explanatory, thank you so much for that.
Thanks for watching!
Seriously well explained! !
Thanks for watching Edwin!
The first iteration a is going to take the value of the second item in the array and b is going to take the first item of the array.
[5, 2]
comparatorFunction(a, b) // a = 2 and b = 5
I see indeed, do you know why ?
Thank you, finally understood
Great! 👍🏻
Thank you.
Very well explained.
Thanks for watching!
Thanks.. you just explained it in simplest way💖
Excellent, thanks for watching!
THANK YOU! Keep up the good work!
Thank you!
This is great. Thank you very much!
Glad it was helpful!
Exactly what I was looking for. Thank you!
Glad to hear! Thanks for watching!!
thank you very much you explained it very well
Thanks for watching!
Excellent explanation.
Glad to hear!
really really thanks a lot🙏🙏 this makes all clear for me about sort method
thanks to you🙏
i really appreciate your efforts sir🙏 thank you so much
this is really appreciable🌸✨ thank you once again for saving me✨
Happy to help!
Great teacher!
Thanks Dragan!
Just what I was looking for, very clear explanation. Thanks 👍
Great to hear!
thanks for the teaching
Thank you for watching!
fantastic explanation !!!! , Thanks much!!!😀
Glad it was helpful!
Thank You, I hope you get more views Sir!.
Thank you too!
This was great, thank you!!
Glad it was helpful!
a tiny correction, in the comparator function, the first argument(a) is actually the second value of a pair of adjacent values being compared.
So in the case of [2, 5, 100, 4], on the first iteration, a is 5 and b is 2. It's a little counter intuitive but in that case, a < b means 5 < 2. If true, we return a negative number, which means a should be before b, that is 5 should be before 2. (This is false)
Else if a > b i.e., 5 > 2, we return positive number, which means b should be before a, that is 2 should be before 5. (This is true)
Thank you, It was really useful
Glad to hear that!
Hi, thanks for the very clear explanation, it's the first video I see which explains it in depth to this extent. There's just something which I was wondering about the comparator function : how exactly does it do the comparison between the different elements in the array? What exactly is happening behind the scenes? Some special kind of algorithm is implemented to compare the elements in a certain order? (is the first element compared to all the other elements of the array, then the second to all the others until the end, etc. or something else?) Hopefully my question makes sense.
Thanks man. This was helpful.
Great to hear!
Very well explained.
Thanks for watching!
such a good content! Keep up the good work. Thanks.
Thank you for watching!
Great explanation thanks 🙏
Thank you for watching!
Loved it you teaching so good Thank you :)
Glad it was helpful!
amazing tutorial!! 😁
Cool, thanks!
THANK YOU FROM MY HEART
Thank you for watching!
Thank you so much, pretty clear explaination! subbed
Thanks for the sub!
Superb explanation!
Glad it was helpful!
if I have 2 numbers in array [ 2, 5]
And I use .sort(...) with comparable fn, and I just console log a and b....5 will show as a, and 2 as b....why is that?
When it was at 09:35 I instantly subscribed! 🤣🤣🤣😇😇
😀 Spice up your life!
superb .. thankyou for this
Thank you too
What I don' t understand is how the values are taken after the first operation?
For example , in the video , in the first step a is 2 and b is 5 so 2 is sorted before 5. However, after that which value is taken as a and b? Is it 2 and 100 or 5 and 100? I am confused. Can someone please explain the step wise process of this sort operation?
well explained sir, thank you :)
Most welcome!
Thank you so much for this
You're so welcome!
wow thank you well explained
Glad it was helpful!