A-Z filter menu - limiting output to one when there are multiples
You can use the group filter and create a 2d array with the letter as the first index and the entries as second index. 

{% set allEntriesByFirstCharacter = allEntries|group('companyName|slice(0, 1)|lower|replace("/[^a-z]/", "0-9")' ) %}


The string passed in the filter will get rendered as an object template an equal results will be grouped by the same key.