Re: How to sort a vector and then append data

From: joel GUERRERO (joegi.geo_at_yahoo.com)
Date: 07/31/04

  • Next message: joel GUERRERO: "passing an allocatable matrix in a subroutine to the main program"
    Date: 30 Jul 2004 17:45:09 -0700
    
    

    Catherine Rees Lay <spamtrap@polyhedron.org.uk> wrote in message news:<0DsVbmDREhCBFw5N@spamtram.polyhedron.com>...
    > In article <bc7de858.0407291749.a785b3c@posting.google.com>, joel
    > GUERRERO <joegi.geo@yahoo.com> writes
    > >Hi,
    > >I'm not very experienced using fortran 90, and probably this will
    > >looks a stupid question for you.
    > >
    > >I need to sort a vector and then append the missing data that is:
    > >
    > >Suppose that we have the following vector: 3 1 2 5 15
    > >
    > >I need to sort it, that is i need to get: 1 2 3 5 15
    > >
    > >and then append the missing numbers in order to get the following
    > >vector:
    > >
    > >1 2 3 -4- 5 -6- -7- -8- -9- -10- -11- -12- -13- -14- 15
    > >
    > >Hoper you can help me,
    > >
    > >Joel
    >
    > OK, that's bizarre, because there's no need to do ANY sorting to get
    > your desired answer. Just find the maximum value in your vector,
    > allocate a new one that long, and set each element equal to its index.
    > Much more efficient than sorting. You'll also need the minimum value and
    > an offset if your minimum value isn't necessarily 1.
    >
    > Of course, if this is a homework problem, you'll have to do it the way
    > you describe. Have a go first and you'll get lots of help here, ask
    > others to do the work for you and you generally won't.
    >
    > Catherine.

    Hi you all,

    Thanks for your help. And it's not homework. I'm writing a program
    for tagging elements in an unstructured mesh, for a posteriori
    refinement.
    Probably I didn't explain myself very clear. The problem is after
    sorting I need to append data in the space between two no consecutive
    numbers. For instance let say that I need to append 1's in that
    space.

    That's:

    1-3-2-5-15-8 then sort it:

    1-2-3-5-8-15 and then append 1's

    1-2-3-1-5-1-1-8-1-1-1-1-1-1-15

    I also need to remove repeated data from an array that is:

    1-2-2-3-4-5-5-6-7-8-9-9-10 from this array i need to remove the
    repeated numbers in order to get:

    1-2-3-4-5-6-7-8-9-10.

    Hope you can help me,

    Joel


  • Next message: joel GUERRERO: "passing an allocatable matrix in a subroutine to the main program"

    Relevant Pages

    • Re: How to sort a vector and then append data
      ... joel GUERRERO wrote: ... || Much more efficient than sorting. ... If there are repeated data, ...
      (comp.lang.fortran)
    • Re: How to sort a vector and then append data
      ... > || Much more efficient than sorting. ... If there are repeated data, ...
      (comp.lang.fortran)
    • Re: How to sort a vector and then append data
      ... >I need to sort a vector and then append the missing data that is: ... Much more efficient than sorting. ... Catherine Rees Lay ...
      (comp.lang.fortran)
    • Re: DataTable - order of rows.
      ... I think that Add will always append the row at the end and using a DataView ... without sorting will reflect this. ... However, to be on the safe side, you might consider using an AutoIncrement ...
      (microsoft.public.dotnet.framework)
    • Re: file numbering
      ... OEX will prepend or append a timestamp to the ... filename as well to allow for sorting based on subject / date or date / ...
      (microsoft.public.windows.inetexplorer.ie6_outlookexpress)