Leading Zeros and reverse sort

Discuss RoboTask here
Post Reply
trotta
Posts: 14
Joined: Thu Sep 27, 2012 3:33 pm
Location: United States

Leading Zeros and reverse sort

Post 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.
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Leading Zeros and reverse sort

Post 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
Post Reply