## 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.

# Problem

NumArray.sort(function(a-b){ return a-b; }); lessons about arrays method - part 2. How exactly this function works? Cant understand how this function sort numbers in order. if I got array of numbers NumArray=[6,2,7,1,3,7]; How that function put them in order.In my mind if you subtract 2 from 6 you got 4.and so on That its obvious But how does it arrange numbers in order after subtraction?

sorts are run by comparison, if a negative number is returned it is pushed to the front. Is the best way I could explain it. alternatively I believe `return a > b ? 1 : a < b ? -1 : 0` would also work to sort an array of numbers.