When I'm Adding users, i want to sort them alphabetically. Could You help. Here is my code:

     SPUserCollection userzyWszyscy2 = witryna.SiteUsers;
        foreach (SPUser oUserKolejny in userzyWszyscy2)


I lean towards using Linq for this:

var listItems = from SPUser u in userzyWszyscy2
order by u.LoginName select new ListItem(u.LoginName)


hope this helps, it is from memory without my trusty IDE to help ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.