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 a sorted internal table

Former Member
0 Kudos

Hi,

If an internal table is sorted or almost sorted, if we sort it again, does it take the same time as it is not sorted at all?


I ask this question because sometimes you do some modifies on a long code which is written by others, you don't want to read the entire code but you need a sorted internal table. If sort a sorted table doesn't take too much time, then I can singly put a SORT before entering LOOP.

Otherwise I have to read the all code to make sure the internal table is sorted only once.

3 REPLIES 3

Former Member
0 Kudos

Hi Ming,

I think it will sort it again and less time take, due to  there is no flag to indicate this itab increased data or not compare with last sort.

regards,

Archer

Former Member
0 Kudos

Hi Ming,

I think we cannot sort the sorted table.

correct me if i am wrong.

Thanks,

Marimuthu.K

matt
Active Contributor
0 Kudos

Ming is saying the table has been sorted, not that it is of type SORTED.

The correct way to approach this is to define your table as SORTED. That way you don't have to worry about whether it is already sorted. If you need more than one sort order, then when you define the table, define the additional sort keys.