Sort Mixed (Numeric First)

JavaScript Medium 5 views
Back to Questions

Problem Description

You get n tokens (strings). If a token is a valid finite number, treat it as numeric. Sort numeric tokens by numeric value. Non-numeric tokens come later sorted lexicographically. Print the final list.

Input Format

Line1: n. Line2: n tokens.

Output Format

One line sorted tokens.

Sample Test Case

Input:
7 10 2 abc -1 2.5 NaN z
Output:
-1 2 2.5 10 abc NaN z

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next