Announcement

Collapse
No announcement yet.

mirroring Data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mirroring Data

    Hi

    to sort a UDT array in the right way. I´ve to mirror the string
    variable first.eg:

    type te
    e as quad
    end type

    dim c(1 to 10) as te

    'fill the array c(1).e=1234567890123 ....

    then I get with ?c(1) = " a3b" ' only example

    and I need "b3a " to sort right

    and I do it slowly with:
    h$=mid$(c(1),8,1)+mid$(c(1),7,1)+mid$(c(1),6,1)+mid$(c(1),5,1)+_
    mid$(c(1),4,1)+mid$(c(1)3,1)+mid$(c(1),2,1)+mid$(c(1),1,1)

    then i can sort the array with

    array sort c(), descend

    and I use the array for an index.

    Before using I need to mirror the key´s again.

    How can I mirror the key´s quicker ?
    (rotate and shift will not work)

    Regards

    Matthias Kuhn

    ------------------

  • #2
    QUADs are stored in Intel order, which do no sort as characters.

    If you want to sort by the numeric value use absolute array method (see your other post) or create a character (string) key. This is not set up for quads but it could get you started...

    NO POST! Damn, I thought I had posted my string signed binary routines.. oh well, you'd have to modify them anyway and don't save much space anyway in this case.

    Or, set up a separate array and sort that, and use a TAGARRAY. If there's no example in the help file, there should be.

    MCM


    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      The point of swapping the bytes around is so the numbers can be sorted as strings.

      The code in Endian.zip should be faster than that sort of string manipulation:

      http://www.powerbasic.com/files/pub/pbwin/misc/

      ...although, this would be an ideal spot for a little assembly language.


      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        pb/dos string signed binary routines posted in source code forum at:
        http://www.powerbasic.com/support/pb...ad.php?t=24029

        mcm
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Hello,

          thanks Michael and Tom for the code. I think both is possible.
          I`ll test it.

          Assembler is not my Power.

          Regards Matthias Kuhn


          ------------------

          Comment


          • #6
            If memory and speed are not primary concerns, Michael's tagarray suggestion allows you to eliminate your second pass of value transformations that undo the first pass of transformations.

            Treat your original array as the tag array, use transformations to build a sort-key array, sort with the tagarray option, then ERASE your sort-key array, leaving your original tag array in sorted sequence.

            With respect to speed, what works best should depend on how many transformations are needed and how you do them (i.e., in ASM or PB).

            ------------------
            Jim C.

            [This message has been edited by Jim Cody (edited October 15, 2003).]
            Jim C.

            Comment

            Working...
            X