Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Excel's Sort Order

After much work, I would like to seek advice and comments regarding
Excel's sort order.

I presume that Excel has its own rules (running in the background)
that enable the standard worksheet sort to sort alphabetically & be
case sensitive ... however, VBA code (using Option Compare Binary or
Text, as required) seems to use the ANSI character set, which puts "A"
before "a" when Binary is set. This would therefore imply that other
sort routines that are based on the ANSI set (QuickSort, MergeSort)
cannot sort truly alphabetically (in Excel VBA) .... or more
realistically, as I would like to sort.

For instance, a case sensitive Excel gives the order AAaa, AAaA, AAAa
( a left to right, character by character comparison, "a" before "A"),
whereas a QuickSort with Option Compare Binary gives AAAa , AAaA,
AAaa.

With Option Compare Text, QuickSort says all 3 are equal, and the
eventual sort order seems dependent on the original list/order …. and
looking at how QuickSort works, I'm not surprised!

A possible solution as, I understand it, is to split the data into
sequential alpha-numeric sections and then either :

* Use a worksheet to sort the sections from the right to the left. The
sort is then stable, and advantage is taken of Excel's internal rules
that enable a true alphabetical, case sensitive sort. It can be made
to be remarkably quick, as long as the sections (ie columns) do not
become excessive.

* Pad numbers, rebuild into a single entity and sort on this data. A
stable sort is required to ensure the original data follows …

It is worth noting that Excel also has its own oddities, ie how it
handles the "." and "-" characters … it sure makes life hard when
trying to sort, and complicates the process of splitting into the
alpha-numeric groups.

Even after the splitting/padding/concatenating, I still cannot get a
standard QuickSort to sort "correctly", as it seems to be based on the
ANSI character set, as noted above.

Any comments would be most welcome.

Regards,

Mark
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
First key sort order M Excel Discussion (Misc queries) 1 December 22nd 08 09:11 PM
Retaining Sort order in the Sort Dialog box CBittinger Excel Discussion (Misc queries) 2 January 9th 08 05:01 PM
Sort sheet based on particuilar sort order Also Excel Worksheet Functions 4 January 3rd 08 09:31 AM
sort last name order amolano8 Excel Discussion (Misc queries) 2 August 17th 06 06:24 PM
sort order DGNVSPORTS Excel Discussion (Misc queries) 3 June 7th 05 07:19 PM


All times are GMT +1. The time now is 02:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"