October 29, 2025, 04:08:27 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Sorting details

Started by Andy, August 07, 2013, 04:48:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

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.





Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Sorry,

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

:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

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
When all else fails, get a bigger hammer.

Bruce Peaslee

I use Access files a lot. They are easily sorted with SQL.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Andy

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


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library