Hello. How to check whether elements are sorted in ascending alphabetical order in the listBox; if the elements are arranged in alphabetical order, then do not sort, if not in alphabetical order, then sort?
Tried so
listBox1.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription(listBox1.SelectedItems[i].ToString(), System.ComponentModel.ListSortDirection.Ascending)); int n = listBox1.Items.Count; string[] strmas = new string[n]; for (int ixdx = 0; ixdx < n; ixdx++) { strmas[ixdx] = listBox1.Items[ixdx].ToString(); } StringComparer comparer = StringComparer.InvariantCulture; Array.Sort(strmas, comparer);