View previous topic :: View next topic
|
Author |
Message |
archana s
New User
Joined: 31 Mar 2008 Posts: 2 Location: Hyderabad
|
|
|
|
Hi,
I have records to be sorted in the order
- all records with positive amounts (increasing in magnitude)
-then all records with negative amounts(increasing in magnitude)
The amounts field is declared with the datatype fixed Decimal(11,2)
{exact rep of that field in hex{000050} ie 35.00c}
{00030C}
eg: consider the input as below
400.00d
600.40d
550.00c
200.00d
200.00c
300.00c where d is pos and c is negative
I have given the sort cord
SORT FIELDS=(756,6,PD,D) [ the field starts at 756 position]
the output i got for this is
600.40
400.00
200.00
200cr
300cr
550cr
but i want the output to be :
200.00
400.00
600.40
200.00cr
300.00cr
550.00cr (in our system the output cr gets appended automatically for the negative no.s) |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
That's a very weird way of representing numbers (d for positive instead of negative?).
At any rate, I believe you can use the following DFSORT SORT statement to get what you want:
Code: |
SORT FIELDS=(761.4,0.4,BI,D,756,5.4,BI,A)
|
It sorts the sign (D or C in descending order so the D values come before the C values) and the digits (not including the sign) in ascending order.
When I sorted these values (shown in hex) at 756:
Code: |
00000040000D
00000060040D
00000055000C
00000020000D
00000020001D
00000020002D
00000020019D
00000020020D
00000020000C
00000020001C
00000020002C
00000020019C
00000020020C
00000030000C
|
I got this output:
Code: |
00000020000D
00000020001D
00000020002D
00000020019D
00000020020D
00000040000D
00000060040D
00000020000C
00000020001C
00000020002C
00000020019C
00000020020C
00000030000C
00000055000C
|
|
|
Back to top |
|
|
archana s
New User
Joined: 31 Mar 2008 Posts: 2 Location: Hyderabad
|
|
|
|
Hi
I have replied long back to this and was waiting on the response ... when i saw today even my reply isn't there...
Can you please explain this sort using decimal digits... i have never used such before .. and thanx this logic worked for me .. thanx a lot.. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Code: |
SORT FIELDS=(761.4,0.4,BI,D,756,5.4,BI,A)
|
I'm using DFSORT's bit sort notation.
761.4,0.4 - means to sort starting at bit 5 of position 761 for 4 bits. So if 761 has X'5C', it will only sort on C and if 761 has X'2D', it will only sort on D. Thus we are sorting on the sign (C or D) first in descending order.
756,5.4 0 means to sort starting at position 756 for 5 bytes and 4 bits. This sorts on the digits without the sign. |
|
Back to top |
|
|
|