Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2020
307
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
RAW Paste Data Copied
Advertisement