Sorting by the last digit
JavaScript
Medium
loops
Task «Sorting by the last digit»
Write a program that reads an array of integers and sorts it in ascending order by the last digit of each number. If the last digits match, the original order is preserved (stable sort). Output the sorted array.
Input Format
The first line contains an integer N (1 ≤ N ≤ 1000). The second line contains N integers separated by spaces.
Output Format
Output N numbers in one line separated by spaces — the sorted array.
Examples
Example 1
INPUT
5
Alice 4
Bob 5
Charlie 4
Diana 3
Eve 5
OUTPUT
Оценка 2: 0
Оценка 3: 1
Оценка 4: 2
Оценка 5: 2
main.js