<?php
use Budgegeria\IntlSort\Builder;
$array = ['àb', 'aB', 'a', 'ab', 'a-b'];
// Primary Strength
// Ignore accents and case
$sortBuilder = new Builder('en_US');
$sorter = $sortBuilder->primaryStrength()
->getSorter();
dump($sorter->sort($array));
// Secondary Strength
// Ignore case, consider accents
$sortBuilder = new Builder('en_US');
$sorter = $sortBuilder->secondaryStrength()
->getSorter();
dump($sorter->sort($array));
// Tertiary Strength
// Consider accents and case
$sortBuilder = new Builder('en_US');
$sorter = $sortBuilder->tertiaryStrength()
->getSorter();
dump($sorter->sort($array));
// Tertiary Strength
// but a-b is considered similar to ab
$sortBuilder = new Builder('en_US');
$sorter = $sortBuilder->tertiaryStrength()
->shiftedAlternateHandling()
->getSorter();
dump($sorter->sort($array));
^ array:5 [
2 => "a"
4 => "a-b"
0 => "àb"
1 => "aB"
3 => "ab"
]
^ array:5 [
2 => "a"
4 => "a-b"
1 => "aB"
3 => "ab"
0 => "àb"
]
^ array:5 [
2 => "a"
4 => "a-b"
3 => "ab"
1 => "aB"
0 => "àb"
]
^ array:5 [
2 => "a"
3 => "ab"
4 => "a-b"
1 => "aB"
0 => "àb"
]