IonicWind Software

IWBasic => General Questions => Topic started by: Andy on August 07, 2013, 04:48:23 AM

Title: Sorting details
Post by: Andy on August 07, 2013, 04:48:23 AM
Hi,

I'm writing a program for a friend of mine, but how can I sort these details?

I have a file, and I read in each record sequentially - one by one.

The details I want to sort for example are:

Smith    Andy    19082013  0800

The details are in separate fields but I would like to sort them like so:


Smith    Andy    19082013  0800
Smith    john     19082013  0800
Thomson Alex    19082013  0800

Edwards A         19082013 0900
Johnson Jim       19082013 0900

Basically,
sort 1 = date e.g. 19082013
sort 2 = start time e.g. 0800
sort 3 = Last name / first name - this is not so important.

Has anyone an idea how I might do this?

Thanks as always,
Andy.





Title: Re: Sorting details
Post by: Andy on August 07, 2013, 05:38:18 AM
Sorry,

forgot to say, I don't want to sort the file - simply to sort the output for printing / displaying on screen.

:)
Title: Re: Sorting details
Post by: LarryMc on August 07, 2013, 08:27:43 AM
A couple of ways come to mind.
If your input file is an ascii text file AND the columns line up you can write a windows command-line batch file and use the SORT command and sort the file on the desired column.  Then from IWB you can invoke the batch file.

The other way is to create a database file with the desired indexes. read in you source file and then query the dbase file on the desired index and print the contents of the result of the query.
Title: Re: Sorting details
Post by: billhsln on August 07, 2013, 09:14:06 AM
Quick and dirty, reformat record to a fixed format:

YYYY-MM-DD HH:MM LastName   FirstName

with our without -'s and :'s.

YYYYMMDDHHMMLastName   FirstName

Then read in and sort as single field or use SORT system command.

Bill
Title: Re: Sorting details
Post by: Bruce Peaslee on August 07, 2013, 09:55:39 PM
I use Access files a lot. They are easily sorted with SQL.
Title: Re: Sorting details
Post by: Andy on August 13, 2013, 07:08:47 AM
Thanks everybody,

Sorry I have not replied lately but my nephew (only 25) died on holiday so my mind has been elsewhere.

but thanks anyway,
Andy.

For Chris  :) xxx


Title: Re: Sorting details
Post by: LarryMc on August 13, 2013, 07:22:46 AM
Quote from: andy1966 on August 13, 2013, 07:08:47 AM
Thanks everybody,

Sorry I have not replied lately but my nephew (only 25) died on holiday so my mind has been elsewhere.

but thanks anyway,
Andy.

For Chris  :) xxx

Sorry for your loss.  Losing one so young can be devastating, I know.