Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2020
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sortArray(input) {
  2.     input.sort(twoCriteriaSort)
  3.     input.forEach(el => console.log(el))
  4.  
  5.     function twoCriteriaSort(cur, next) {
  6.         if(cur.length > next.length) {
  7.             return 1
  8.         } else if(cur.length < next.length) {
  9.             return -1
  10.         } else {
  11.             return cur > next
  12.         }
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement