Guest User

Untitled

a guest
Dec 10th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. /**
  2. * Boolean overview
  3. * if (a < b) {
  4. * // do this because it's true
  5. * } else {
  6. * // do this because it's false
  7. * }
  8. */
  9.  
  10. const arr = [4,1,2,5,3,2];
  11.  
  12. function ascendingSortBool(a,b) {
  13. return +(a > b) || -(a < b)
  14. }
  15. console.log(`Ascending -> `, .sort(ascendingSortBool)) // [ 1, 2, 2, 3, 4, 5 ]
Add Comment
Please, Sign In to add comment