Welcome to the North American Subaru Impreza Owners Club Thursday March 28, 2024
Home Forums Images WikiNASIOC Products Store Modifications Upgrade Garage
NASIOC
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.







* As an Amazon Associate I earn from qualifying purchases. 
* 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 online now   Reply With Quote
Sponsored Links
* Registered users of the site do not see these ads.
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 online now   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 06:47 PM.


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

As an Amazon Associate I earn from qualifying purchases.

When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission
Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network.