Serious SORTING Problems!

 BBS: Inland Empire Archive
Date: 02-15-94 (21:01)             Number: 65
From: PETER MIKALAJUNAS            Refer#: NONE
  To: MARK SPIVEY                   Recvd: NO  
Subj: Serious SORTING Problems!      Conf: (2) Quik_Bas
MS> Ok,  get this, A sort program I found in a QB manual will
MS> now work either,  It sorts anything, and you specify the
MS> location and length of the key it sorts by,  but it does the
MS> following

MS> 01/01/80
MS> 01/01/92
MS> 02/02/81
MS> 02/03/90

MS> Keep in mind that I am using the same string type as above
MS> as the key for the sort.  HELP!!!!!!!!!!!!!!!!

Sure, be glad to help.  How does this sound?

CLS
OldDate$ = "02/03/90"
PRINT "The Original Date was " + OldDate$
PRINT "Which is very hard to sort as string."
' Mid$ makes the whole thing a snap.
Mth$ = MID$(OldDate$, 1, 2)
Dy$ = MID$(OldDate$, 4, 2)
Yr$ = MID$(OldDate$, 7, 2)
' now it will be simple for you convert all your stored
dates and ' sort them correctly
Slash$ = "/"
NewDate$ = Yr$ + Slash$ + Mth$ + Slash$ + Dy$
PRINT
PRINT "So we changed to something more useful like " + NewDate$
PRINT "Which is very easy to sort as a string :-)"

 * SLMR 2.1a * Daddy, when cows laugh, does milk come out their nose?
$$51
--- GEcho 1.00
 * Origin: The Hideaway BBS 708.748.1911 HST/V32bis    (1:115/748)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET