Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 18 in printed book and digital formats -- plus a one-year subscription (beginning with 19.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 5.2

COLUMN

Sorting Arrays

Bring Order To Your Objects

Issue: 5.2 (January/February 2007)
Author: Charles Yeomans
Author Bio: Charles is the author of "I Declare: Calling External Functions in REALbasic", available online at http://www.declareSub.com
Article Description: No description available.
Article Length (in bytes): 10,734
Starting Page Number: 38
Article Number: 5215
Related Web Link(s):

http://www.declareSub.com

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.