Page 1 of 1

Leading Zeros and reverse sort

Posted: Wed Dec 19, 2012 10:11 am
by trotta
I need to add a six digit sequence number to a line of text. The sequence number needs leading zeros.  This is so it can be sorted in reverse order after the file has the correct sequence number.
This is what I have now:
 
text  1
text  2
text  3
text  4
 
What I need is:
 
text  000001
text  000002
text  000003
text  000004
 
So it can then be sorted like this:
 
text  000004
text  000003
text  000002
text  000001
 
Any help would be appreciated.

Leading Zeros and reverse sort

Posted: Wed Dec 19, 2012 11:23 am
by Oleg
I think that the text may be different, but the length is the same.

The problem is that you may sort text by whole lines and leading symbols have priority.
So, we need to place number into begin of line -> sort the text -> remove leading numbers.

Look at this example: sort by numbers at the end of line.tsk

This task does the following:
- extracts the number from the end of each line
- adds leading zeros
- makes such lines in the text: 000003text 000003
- sorts the text
- removes leading numbers

Save the task into a file and use menu Task -> Import to import into RoboTask