Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

83
Views
sorting by first digit

I have array [1, 2, 3, 4, 10, 11, 12, 20, 29, 30, 39, 40, 49, 101, 110, 119, 123]

I want to sort by keeping first digit e.g

1
10
101
11
110
119
12
123
2
20
29
3
30
39
4
40
49

is there a correct name for this sort? tried text and different methods unsure how to do this

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.sort() should reorder the items like that by default.

The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.

console.log(
  [1, 2, 3, 4, 10, 11, 12, 20, 29, 30, 39, 40, 49, 101, 110, 119, 123].sort()
);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!