Skip to content

Latest commit

 

History

History
58 lines (37 loc) · 1001 Bytes

README.md

File metadata and controls

58 lines (37 loc) · 1001 Bytes

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));