Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const chars = '0123456789aábcdeéfghiíjklmnoóöőpqrstuúüűvwxyz';
- export function compare(a, b) {
- a = a.toString().toLowerCase();
- b = b.toString().toLowerCase();
- if (a === b) {
- return 0;
- }
- let posA = 0;
- let posB = 0;
- let locA = chars.indexOf(a.charAt(posA));
- let locB = chars.indexOf(b.charAt(posB));
- while (locA === locB) {
- locA = chars.indexOf(a.charAt(++posA));
- locB = chars.indexOf(b.charAt(++posB));
- }
- if (locA > locB) {
- return 1;
- }
- if (locA < locB) {
- return -1;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment