Welcome to the North American Subaru Impreza Owners Club Sunday July 13, 2014
Home Forums WikiNASIOC Products Store Modifications Upgrade Garage
NASIOC
Here you can view your subscribed threads, work with private messages and edit your profile and preferences Home Registration is free! Visit the NASIOC Store NASIOC Rules Search Find other members Frequently Asked Questions Calendar Archive NASIOC Upgrade Garage Logout
Go Back   NASIOC > NASIOC Miscellaneous > Off-Topic

Welcome to NASIOC - The world's largest online community for Subaru enthusiasts!
Welcome to the NASIOC.com Subaru forum.

You are currently viewing our forum as a guest, which gives you limited access to view most discussions and access our other features. By joining our community, free of charge, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is free, fast and simple, so please join our community today!

If you have any problems with the registration process or your account login, please contact us.
* Registered users of the site do not see these ads.
Reply
 
Thread Tools Display Modes
Old 10-04-2012, 11:42 AM   #1
fliz
Scooby Guru
 
Member#: 30342
Join Date: Nov 2002
Location: #blp
Default 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.
fliz is offline   Reply With Quote
Old 10-04-2012, 12:05 PM   #2
FellowTraveller
Scooby Newbie
 
Member#: 161570
Join Date: Oct 2007
Chapter/Region: E. Canada
Location: St. John's Newfoundland Canada
Vehicle:
2007 Impreza
Newport Blue Pearl

Default

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)
FellowTraveller is offline   Reply With Quote
Old 10-04-2012, 12:32 PM   #3
fliz
Scooby Guru
 
Member#: 30342
Join Date: Nov 2002
Location: #blp
Default

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.
fliz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 02:17 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Powered by Searchlight © 2014 Axivo Inc.
Copyright ©1999 - 2014, North American Subaru Impreza Owners Club, Inc.