|
|
|
|
Thread Tools | Display Modes |
10-04-2012, 11:42 AM | #1 |
Scooby Guru
Member#: 30342
Join Date: Nov 2002
Location: #blp
|
Nerd Help: ASCII Sorting
I have a programming problem that needs help.
We need to pad a rev series so it can be sorted by a downstream program. The sorting algorithm sorts by length first (shorter string < longer), then does a simple ascii sort. This worked great when the data started at A, then went AA, AB, etc, up to ZZ. But now we have a new data series, and need a simple algorithm to pad the values so they work with the sorting algorithm. New Values: - # -A {...} -Z -AA 0 1 {...} 9 00 01 {...} 99 -- A B {...} Z AA {...} AZ BA {...} ZZ AAA {...} ZZZ
* Registered users of the site do not see these ads.
|
10-04-2012, 12:05 PM | #2 |
Scooby Newbie
Member#: 161570
Join Date: Oct 2007
Chapter/Region:
E. Canada
Location: St. John's Newfoundland Canada
Vehicle:2007 Impreza Newport Blue Pearl |
1. Learn Perl and bash
2. Use unix sort command 3. Use unix sed / awk commands 4. Profit (literally since this is your work homework) |
10-04-2012, 12:32 PM | #3 |
Scooby Guru
Member#: 30342
Join Date: Nov 2002
Location: #blp
|
I didn't mention we're using java to write this data into an Oracle database where it will be accessed/processed by the downstream system. Cannot modify the sorting algorithm, must modify the data.
so far, we've come up with: - # -A -AA ---0 --99 ----- ----A --ZZZ Which is just messy because we have to hard code a bunch of rules that may not apply forever. |
Thread Tools | |
Display Modes | |
|
|