Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort letter and number js

let arr = [
  [10, 2],
  ["a",3],
  [2.2, "d","h",6,"s",14,1],
  ["f", "e"],
  ["p","y","z","V"],
  [5]
]

let val = arr.flat()

val = [
  ...val.filter(v => typeof v === "number").sort((a, b) => a - b),
  ...val.filter(v => typeof v === "string").sort()
]
console.log(val)
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #sort #letter #number #js
ADD COMMENT
Topic
Name
1+7 =