Skip to content

Sorting text with the Hungarian spelling rules.

License

Notifications You must be signed in to change notification settings

janosorcsik/hunsorter

Repository files navigation

hunsorter

Sorting text with the Hungarian spelling rules.

Installation

npm install hunsorter

How to use

Simple sorting (ascending)

import sorting from hunsorter;

const fruits = ['narancs', 'alma', 'körte'];

fruits.sort(sorting);

Simple sorting (descending)

import sorting from hunsorter;

const fruits = ['narancs', 'alma', 'körte'];

fruits.sort((a, b) => sorting(b, a));

Sorting with key

import sorting from hunsorter;

const fruits = [
  { name: 'narancs' },
  { name: 'alma' },
  { name: 'körte' }
];

fruits.sort((a, b) => sorting(a.name, b.name));

Sorting with multiple keys

import sorting from hunsorter;

const fruits = [
  { name: 'narancs', color: 'sárga' },
  { name: 'alma', color: 'piros' },
  { name: 'körte', color: 'sárga' },
];

fruits.sort((a, b) => sorting(a.color, b.color) || sorting(a.name, b.name));