Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Algorithms

Sorting Arrays

Bring Order To Your Objects

Issue: 5.2 (January/February 2007)
Author: Charles Yeomans
Article Description: No description available.
Article Length (in bytes): 9,500
Starting Page Number: 38
RBD Number: 5215
Resource File(s): None
Related Web Link(s):

http://www.declareSub.com

Known Limitations: None

Excerpt of article text...

The next few Algorithms columns will tackle the subject of sorting. Along with searching, sorting is one of the fundamental algorithmic tasks in programming. I'll cover some of the standard sorting algorithms, after which you may be better equipped to use them in your own projects. We begin with the definitions.

What is Sorting?

For our purposes, sorting is the following operation. Given an array A and a function that defines a comparison between any two elements, to sort the array means to reorder the elements so that A(i - 1) <= A(i) for all i in the range from 1 to UBound(A).

There is a stronger concept called stable sorting. A stable sort is a sort that preserves the relative order of equal elements. That is, suppose element1 and element2 are elements of the array A, and element1 = element2. If A.IndexOf(element1) < A.IndexOf(element2) before sorting, then after a stable sort, A.IndexOf(element1) < A.IndexOf(element2) remains true even though the elements may have been moved from their original positions.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com