In Xcode (Swift) I have an array that is initialized to 100 empty items:
var persons = [String](count:100, repeatedValue: "")
With some functions I add content to the places in the array, starting at 0.
So for example my array is at some given moment:
["Bert", "Daniel", "Claire", "Aaron", "", "", ... ""]
With the dots representing the rest of the empty items. I use this function for sorting my array alphabetically:
persons = persons.sorted {$0.localizedCaseInsensitiveCompare($1) == NSComparisonResult.OrderedAscending }
This gives me an array back like this:
["", "", ... , "Aaron", "Bert", "Claire", "Daniel"]
What I want is to sort my array alphabetically but not with the empty items at the front. I need to get an array back like:
["Aaron", "Bert", "Claire", "Daniel", "", "", ... , ""]
For my part, I do not want an array with empty items but I found I couldn't add a value to my array if I did not declare like a 100 items (the array won't be filled to a 100 items, that's for sure).
Can anyone help me out?