Windows Phone Developers

Tuesday, May 6, 2008

Creating and Sorting an ArrayList

Example of System.Collections namespace in ArrayList

The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries. Arraylist is one of the basic collection; it implements the IList interface using an array whose size is dynamically increased as required

Imports System.Collections

Sub Main()

Dim aList As New ArrayList

Dim arStr() As String = {"Apple", "Aaron", "Byron", "Reddy"}


For Each aLis As String In aList




‘Sort Array


For Each aLis As String In aList



End Sub

This method uses Array..::.Sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.

On average, this method is an O(n log n) operation, where n is Count; in the worst case it is an O(n^2) operation.

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment