# 29. 整型数组按个位值排序

29

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function(line) {
    const list = input.split(',').map(Number);
    list.sort((a, b) => getKey(a) - getKey(b));

    function getKey(i) {
        i = i > 0 ? i : -i;
        return i % 10;
    }
    console.log(list.join(','));
})

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17