> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/s/sort_using_a_custom_comparator.md).

# Sort using a custom comparator

Primary sort by length of string, then break ties by sorting alphabetically (ignoring case).

```perl
my @strings = <Here are some sample strings to be sorted>;
put @strings.sort:{.chars, .lc};
put sort -> $x { $x.chars, $x.lc }, @strings;
```

#### Output:

```
be to are Here some sample sorted strings
be to are Here some sample sorted strings
```
