Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Sort logic

Former Member
0 Kudos

Hi,

I have the following known values on the left hand side

1----


(1)

10----


(5)

10.5-------(6)

1.5----


(2)

2----


(3)

2.5----


(4)

and would want to give a number in parentheses to the corresponding number on the left hand side, so when sorting the number in parentheses the number will be sorted in the following order:

1----


(1)

1.5----


(2)

2----


(3)

2.5----


(4)

10----


(5)

10.5----


(6)

How would I write a logic to assign the numbers in paraentheses to the number on the left hand side?

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

this field should be type P and give decimals as per your requirement then it will work.

Reward points if it is useful.

Phanindra

8 REPLIES 8

Former Member
0 Kudos

concatenate '(' lv_number ')' into lv_paranthesis.

increment the lv_number for every record.

Reward the points if useful.

0 Kudos

Each number in the parentheses does not necessarily have to be in parentheses per your suggestion; it is just an example to explain my approach.

Maybe I shoud rephrase the question:

I have the following know numbers

1

10

10.5

1.5

2

2.5

and would want to sort them in the following order. How would I write a logic to get the sorted results?:

1

1.5

2

2.5

10

10.5

Thanks

Former Member
0 Kudos

if that field type is character it will sort automatically. what is the field type.

0 Kudos

first sort tne table by ascending order and

loop through each record incrementing the counter and concatenate the braces to it for the second field

i hope this should help you .

Cheers

Srinu reddy.

0 Kudos

It is a type CHAR and I want to sort it to be of type number in sequence 1, 1.5, 2, 2.5...10 and not of tyoe CHAR in the following order

1

10

10.5

1.5

2

2.5

Thanks

Former Member
0 Kudos

this field should be type P and give decimals as per your requirement then it will work.

Reward points if it is useful.

Phanindra

0 Kudos

That's the main purpose of this question. The type must be CHAR, and the values are numbers. So I trying to find a way to somehow give the sequence of indexes for these numbers and sort by the index. I am trying to see if anyone has done this and can give me some pseudo code. This was explained originally when I posted the question.

I have a table of these value numbers but the field is type CHAR. When I sort the column field, it will sort according to type CHAR, but I want to see the numeric sort for this column. I was thinking that I would add another field to this table and give the column field the type P, but how would I write a program to determine what index of type P to assign to the field column of type CHAR. Each field of type CHAR will have the index value of type P, and I would sort using the index field and not the field type CHAR.

Thanks

Former Member
0 Kudos

Hi,

As you said, have an another column with type P..

Then when you move the values to the character field move the same value to the type P field also..

When you sort ...sort by the type P column..

Thanks,

Naren