Sorting problem

I seem to be misunderstanding something basic about sorting from data files. I am trying to input data from a sequential file, and sort it by one of the variables, highest to lowest, and then print the three highest ... not the variable but the associated name attached to the variable. For example the data file would look like this:

"One",24,46,48,
"Two",54,21,13,
"Three",12,66,11,
"Four",100,10,13,
"Five",12,100,26,

The Name$ variable values are One, Two, Three, Four, Five. If I sort by the second numerical variable, I want it to be able to print highest to lowest, the top two or three (or any number of course), for example:

Five Three One

I think this should be straightforward but I don't seem to be putting it together from the text I am trying to learn from. Thanks if you can help.
--Shakes

Comments

  • : I seem to be misunderstanding something basic about sorting from data files. I am trying to input data from a sequential file, and sort it by one of the variables, highest to lowest, and then print the three highest ... not the variable but the associated name attached to the variable. For example the data file would look like this:
    :
    : "One",24,46,48,
    : "Two",54,21,13,
    : "Three",12,66,11,
    : "Four",100,10,13,
    : "Five",12,100,26,
    :
    : The Name$ variable values are One, Two, Three, Four, Five. If I sort by the second numerical variable, I want it to be able to print highest to lowest, the top two or three (or any number of course), for example:
    :
    : Five Three One
    :
    : I think this should be straightforward but I don't seem to be putting it together from the text I am trying to learn from. Thanks if you can help.
    : --Shakes
    :
    :
    Make a sorting algorithm that's sorting a TYPE.
    [code]
    TYPE
    a AS STRING*5
    b AS INTEGER
    END TYPE

    'sorting algorithm...
    [/code]
    ===============================
    El [b]PRO[/b]grammador Niklas Ulvinge

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion