No announcement yet.

mirroring Data

  • Filter
  • Time
  • Show
Clear All
new posts

  • mirroring Data


    to sort a UDT array in the right way. I´ve to mirror the string

    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:

    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)


    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.


    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]


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

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

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

      Tom Hanlin
      PowerBASIC Staff


      • #4
        pb/dos string signed binary routines posted in source code forum at:

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]


        • #5

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

          Assembler is not my Power.

          Regards Matthias Kuhn



          • #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.