php :/

Associate
Joined
26 Jan 2006
Posts
1,502
I need to furnish an identical function to asort($list) of PHP. However, I am not sure how to handle a mix of strings and numbers while sorting.

I could do something like

foreach($list as $value)
if pos > pos+1 swap


a simple bubble sort, but how about an array(1,2, this, 5, is, consufing)?

You can sort this with bubble sort?

Thanks a lot!
 
code wont help me, thats why I talked psudo code in the fist place :)

I aim to learn not copy.

OK, the problem is that I can sort an array if its only integers!

However, if there is a mixure of strings, integers, doubles how i can compare the pairs and implement a bubble sort?

For example,

if (test > 1) what will yield?
 
basically, I need to sort Strings in alphabetical order only for now.

You think I need to visit every position in the string and determine that by comparing it to all others? or there is an easier way?
 
Back
Top Bottom