![]() ![]() ![]() ![]() Sorted = False Catch GeneralException As Exception MsgBox( "You can't sort an ArrayList whose items " & _ Notice that there is no overloaded form of the Sort method that sorts a section of the ArrayList.Ĭatch SortException As InvalidOperationException The other two forms of the Sort method use a custom function for comparing items you will see how they’re used in the section “Custom Sorting,” later in this chapter. If the items stored in the ArrayList are of a data type other than the base data types, you must supply your own mechanism to compare the objects. You’ll see how you can handle this exception shortly. If the items are not all of the same type, an exception will be thrown. The first form of the Sort method sorts the ArrayList alphabetically or numerically, depending on the data type of the objects stored in it. aList is a properly declared and initialized ArrayList object. The ArrayList’s Sort method doesn’t require you to pass the name of the ArrayList to be sorted as an argument unlike the Sort method of the Array class, this is an instance method and sorts the ArrayList object to which it’s applied. Sort( startIndex, endIndex, comparer) Code language: CSS ( css ) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |