Hi
I have an array (which comes from a search result) with words and numbers.
How do I sort it 0-9+A-Z and Z-A+9-0?
Thanks!
Printable View
Hi
I have an array (which comes from a search result) with words and numbers.
How do I sort it 0-9+A-Z and Z-A+9-0?
Thanks!
other character i.e + & - are alternating in ur sequence
Is tat sequence should be followed same or it not compulsion
What is your actual question?
Do you need a sorting routine or do you have a sort routine but you need a different order?
Can you post your professor's actual assignment? We might better understand your issue.
What I THINK you want is that you ahve something like this:
and you might want it sorted, first, like this:Code:4
3
5
a
D
3
t
4
9
V
and then like this:Code:3
3
4
4
5
9
a
t
D
V
(Or, you might also not care if the letters are caps or not, in which case the first of the two sorts I would expect would look like this:Code:V
D
t
a
9
5
4
4
3
3
good guess?Code:3
3
4
4
5
9
a
D
t
V
Well, the SIMPLE way to do 1/2 of it, is to put the values in a listbox (with the property sorted set to true). BUT, I know you are looking for a sorting algorithm so you can reverse the process as well. If you google sorting arrays, you will find a lot of hints. I am sure someone will gin up something for you as well...I will if I have time....busy right now.
While you could go shopping in the CodeBank here for a thread covering many common sorting algorithms, it sounds like all you need is simple sorting of String arrays.
One algorithm that is fast and doesn't have the risk of nasty worst-case performance and possible self-destruction (I'm looking at you, Quick Sort) is the Heap Sort. I have one with both ascending and descending sorts and several compare options: Binary, Text, and "Insensitive."
The risk with a Text comparison is that some differing characters compare lexically as equal even though they are different, and characters such as hyphens and apostrophes can be ignored as insignificant. However "Insensitive" compares is the slowest of the three options.
Most of the size of the attachment is due to included sample data.
Thanks both of you :)
When I tried to test the sample above each time a run-time error appears. The app requires a reference to "Edanmo's OLE interfaces & functions v1.81" ... It seems this reference is not related to the sort function in any way as long as once it is eliminated everything works properly.
Ahh, good point. Thank you for bringing it up.
It was left in there when this was created from a much larger, older Project. I will repost the archive to spare future viewers that problem.
This is a very commonly used TLB so a lot of people will never have bumped into it. Sorry.