Javascript 데이터 정렬하기

2024. 12. 5. 17:35Javascript

asc

const replacements = { 'YYYY': '2024', 'HH24': '15', 'HH': '03', 'MI': '12', 'SS': '45' };
const keys = Object.keys(replacements).sort((a, b) => a.length - b.length);

desc

const keys = Object.keys(replacements).sort((a, b) => b.length - a.length);