handle grouping of empty lists
header key has already been stripped from the line
fix wrong name: ordered -> sorted
fix incorrect function name