Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Gary Calhoun
10,317 PointsUnderstanding the sort() function?
var myarray=[7, 40, 300]
myarray.sort() //Array now becomes [300,40,7]
Original source http://www.javascriptkit.com/javatutors/arraysort.shtml
In mathematics, the lexicographic or lexicographical order (also known as lexical order, dictionary order, alphabetical order or lexicographic(al) product) is a generalization of the way the alphabetical order of words is based on the alphabetical order of their component letters.
I don't understand this Three Hundred, Forty, and Seven
How is Seven larger alphabetically shouldn't Three Hundred be larger because it begins with T?
1 Answer
Seth Kroger
56,416 PointsBecause it's translating the numbers into character strings for the numbers, not the English words for the numbers. Lexically the character '3' comes before the character '7'.
Gary Calhoun
10,317 PointsGary Calhoun
10,317 PointsOh haha thanks man I was going crazy.