By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 460,014 Members | 1,375 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,014 IT Pros & Developers. It's quick & easy.

# Sorting of numbers or strings.

 P: n/a I don't know whether the inputs are all numbers or all strings... if they are numbers, they are sorted as numbers, if they are strings, they are sorted as strings.... e.g. input : 9 12 2 4 output : 2 4 9 12 input : orange Banana ouput : Banana orange How can I do so?? Nov 14 '05 #1
Share this Question
3 Replies

 P: n/a Mars wrote: I don't know whether the inputs are all numbers or all strings... if they are numbers, they are sorted as numbers, if they are strings, they are sorted as strings.... e.g. input : 9 12 2 4 output : 2 4 9 12 input : orange Banana ouput : Banana orange How can I do so?? What are you going to do with: input : 9 orange 12 2 banana 4 -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson Nov 14 '05 #2

 P: n/a In article <42**********@rain.i-cable.com>, Mars wrote: :I don't know whether the inputs are all numbers or all strings... :if they are numbers, they are sorted as numbers, :if they are strings, they are sorted as strings.... Which part are you asking for assistance on? Reading values? Deciding whether they are all numeric? Sorting? -- Those were borogoves and the momerathsoutgrabe completely mimsy. Nov 14 '05 #3

 P: n/a Mars wrote: I don't know whether the inputs are all numbers or all strings... if they are numbers, they are sorted as numbers, if they are strings, they are sorted as strings.... e.g. input : 9 12 2 4 output : 2 4 9 12 input : orange Banana ouput : Banana orange You might find http://sourcefrog.net/projects/natsort/ helpful. (Yes, that's "frog," not "forge.") Last time I looked, the C implementation had several occurrences of the "pass a plain `char' to a function" error, but those are easily repaired. -- Er*********@sun.com Nov 14 '05 #4

### This discussion thread is closed

Replies have been disabled for this discussion.