JSFiddle - React, Tailwind, and code Playground
JavaScript
const arr = ['63', '34', '10', '8', '12'];
// to sort
// weight 6 + 3 = 9
// 3 + 4 = 7
// 1 + 0 = 1
// 8 = 8
// 1 + 2 = 3
const newArr = ['10', '12', '34', '8', '63'];
function makeSorting (arr) {
const result = arr.map(item => item.split('').reduce((prev, next) => {
return prev + parseInt(next);
}, 0));
console.log(result);
}
makeSorting(arr);