[ngrams] more refactoring, ordering by occurrences fixed

3 jobs for 149-dev-ngrams-table-sorting-fix in 92 minutes and 4 seconds (queued for 83 minutes and 9 seconds)
Status Job ID Name Coverage
  Test
passed #5277
deps

00:29:49

passed #5278
docs

00:31:20

passed #5279
test

00:30:53