The MASM Forum

General => The Campus => Topic started by: icelated on August 05, 2012, 04:14:40 PM

Title: sorting string dates
Post by: icelated on August 05, 2012, 04:14:40 PM
I am currently reading in a file of 3 books which include (author, title, and date) and printing it.
What i want to do is sort it by date. Im not picky on what to use.

I think i need to check for carriage returns
I think i  need to convert to number's and store them in separate registers. Even, if thats true not sure where to begin!

Im just not sure what to do. I  need some type of algorithm needed to accomplish this.
Or some help

I know i will need some type of case for the month

here is the part that reads in the file and prints it.




read_file MACRO

   
    mov hFile, fopen("input.txt")


     print chr$(" ",13,10)
     fclose hFile

ENDM




here is the file


3

Owl Knight
NOV-30-2000

Title: Re: sorting string dates
Post by: jj2007 on August 05, 2012, 06:07:01 PM
Convert the entries to format
20091223<tab>Name<tab>etc
and use a simple string sort.

Wrong sub-forum, by the way - your code is 32 bit. Moderator will move it to the campus, I suppose.
Title: Re: sorting string dates
Post by: icelated on August 06, 2012, 03:38:52 AM
What can i use for the string sort? Is there some type of comparison? like a bubble sort?

I cant access the other forum(masm32). I register and they say they send me an email but i never get it. I tried different emails.
So i can use the 3 in the file to know where to look for the date? grab bits and store it in different registers?
Title: Re: sorting string dates
Post by: fearless on August 06, 2012, 05:09:44 AM
If you know the format of the date strong and verify it is correct, you could convert the string date to julian date format - which gives an integer as the date value, which can then be used to compare dates for sorting
Title: Re: sorting string dates
Post by: jj2007 on August 06, 2012, 06:26:00 AM
Are you aware of #9 (http://masm32.com/board/index.php?topic=4.0)?
Title: Re: sorting string dates
Post by: dedndave on August 06, 2012, 10:57:15 AM
i think there is a function written for you in the masm library
look at the help files in the masm32\help folder