retrieve local users, groups and group members in a sorted way

Fixes #10268 

please review @icewind1991 @Xenopathic @MorrisJobke