in reply to Re: Exceptional sorting
in thread Exceptional sorting

0000 should remain between 1245 and 1246.
@ar = ( 1245, 0000, 1246, 1247, 1248 );
after sorting.

Replies are listed 'Best First'.
Re: Exceptional sorting
by Abigail-II (Bishop) on May 25, 2004 at 11:07 UTC
    Why? Why not between 1247 and 1248? If you don't say why 0000 stays between certain numbers, I'd have to ask 120 questions to be able to sort a set of five numbers.

    Abigail

      It is times. Station a: (sorted)
      {Train 0 => 1230, Train 1 => 1244, Train 2 => 1245 , Train 3 => 1247 }
      Station b: Train 3 does not stop here, so time is 0000. But I know it is following Train 1.
      {Train 1 => 1245, Train 2 => 0000 , Train 3 => 1248 }
      I will take the existing order of trains, and calculate the next station.
      But trains can be overtaken by other trains in which case I will have a time for the train. So if as station c Train 1 overtakes Train 3 but Train 2 has no time the array would be { Train 0 => 1245, Train 1 => 1255, Train 2 => 0000, Train 3 = 1250 }. In that case my sorting needs to set Train 1at the end, while the other trains need to be kept in order. It is not 5 entries but a couple of 100000s of times that need to be sorted.
        Well, then you basically have two-dimensional data, from which more information can be deduced than the one-dimensional problem you first presented. I'd work with the two-dimensional data, and not flatten out all the times in a big list.

        Abigail

        I believe that you can't get the topology of the train tracks and stations from the data you supply. You have the presented following table :

        Station aStation bStation c
        Train 01230????1245
        Train 1124412451255
        Train 2124500000000
        Train 3124712481250

        and you want to read from that table the following train track layout:

        Station a Station b Station c --[]------->-------[]------>------[]--- \ (Train 0,1,2) / \ / \-------->---------/ (Train 3)

        If that's what you want, it will be impossible, so you have to show much more of the implicit external knowledge about when one train overtakes another train and other rules which you don't mention.

        I will take the existing order of trains, and calculate the next station.
        So, you want to create a function that will predict, based on the times for the N previous stations, what time the trains will arrive at station N+1?

        --Solo
        --
        You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.