Sorting by the last digit

Swift Easy sorting

Task «Sorting by the last digit»

Write a program that sorts an array of integers in ascending order by the last digit. If the last digits are equal, the numbers should be sorted in ascending order of the number itself. The array consists of integers, each from -1000 to 1000. The length of the array does not exceed 100.

Input Format

The first line contains an integer N (1 ≤ N ≤ 100) — the number of values. The second line contains N integers separated by spaces.

Output Format

Output N numbers in sorted order, separated by spaces.

Examples

Example 1

INPUT
3 -5 0 5
OUTPUT
0 -5 5

Example 2

INPUT
{"x":"hello"} {"x":"world"}
OUTPUT
{ "x": "world" }

Example 3

INPUT
{"n":null} {"n":{"k":1}}
OUTPUT
{ "n": { "k": 1 } }
main.swift