Sort an array by value using Python

Question:

Write a program that sorts an array by its data value python, the output will be like this

Here is my code so far

iniArray = ['a', '1', 'b', '2', 'c', '3']
iniArray.sort(key=str, reverse=False)
print(iniArray)

Output expected :

print(iniArray) 
['a', 'b', 'c', '1', '2', '3']
Asked By: nopedawn

||

Answers:

Code

iniArray = ['a', '1', 'b', '2', 'c', '3']
sorted(iniArray, key=lambda x: x.isdigit())

Output:

['a', 'b', 'c', '1', '2', '3']
Answered By: Stackpy
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.