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.
Sorry,
forgot to say, I don't want to sort the file - simply to sort the output for printing / displaying on screen.
:)
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.
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
I use Access files a lot. They are easily sorted with SQL.
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
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.