I have an array that i am using in a picker. I would like this array to be alphabetic.
The array is
var item = ["Dog", "Cat", "Ant", "Zoo"]
@State private var selectedItem = 0
The picker is
Picker(selection: $item, label: Text("Item")){
ForEach(0 ..< selectedItem.count){
//this is the made selection
Text(self.item[$0])
}
}
How would i go about making this alpha, i have tried sort() which didnt work for me. It is however, very possible, that i didnt do it right.
Help is always appreciated.
Kind Regards
Adam