sortByWeight question
JavaScript
const arr = ['123', '22', '45', '1'];
const sortByWeight = arr => {
// logic...
}
// ['123', '22', '45', '1']
// 1 + 2 + 3 = 6; 2 + 2 = 4; 4 + 5 = 9; 1
// weights: [6, 4, 9, 1]
// sorted by weights: ['1', '22', '123', '45']