Sort groups and files in a meaningful and consistent way.