Move capital letters to the beginning
const result = [...'Hello World Foo Bar'] .sort((a, b) => /[A-Z]/.test(a) ? /[A-Z]/.test(b) ? 0 : -1 : 0) .join(''); return result;
Source: stackoverflow.com
const result = [...'Hello World Foo Bar'] .sort((a, b) => /[A-Z]/.test(a) ? /[A-Z]/.test(b) ? 0 : -1 : 0) .join(''); return result;