WordBasic and Table ANSI Sort Order Not the Same

ID: Q121252


The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a


SUMMARY

WordBasic (the Word macro language) uses a different ANSI character sort order than that used by the Sort Text command on the Table menu in Word.

Furthermore, the ANSI character sort order differs between Word for the Macintosh and Word for Windows, both for WordBasic and for the Table Sort Text command. In other words, there are four different ANSI character sort orders:


   Word for the Macintosh         Word for Windows
   ----------------------         ----------------

   WordBasic ANSI character       WordBasic ANSI character
   sort order                     sort order (see list below)

   ANSI character sort order      ANSI character sort order
   used by Sort Text command      used by Sort Text command
   on the Table menu              on the Table menu (see list
                                  below) 
This article contains a list of only the Word for Windows ANSI character sort orders used by the English (US) version of Word for Windows, running under the English (US) version of Microsoft Windows. This article does not contain a list of the Word for the Macintosh ANSI character sort orders.


MORE INFORMATION

The specific sort order of ANSI characters is relevant when you write WordBasic macros that compare items based on their sort order. The sort order is quite predictable for alphabetic and numeric characters (for example, A comes before B, 3 comes before 4, and so forth). However, the sort order for the remaining characters is not predictable, so a sort order list is helpful. For example, to determine whether "!" is greater or less than "?", you must refer to a sort order list (or run a SortArray macro to sort the characters).

Sort Order Used By Table Sort Command - Windows Environment

In Word for Windows, the sort order used by the Sort command on the Table menu is based on an algorithm that considers the international version of both Windows and Word. The following is the logic of the algorithm:

  1. If the Windows language class is the same as that used by Word, the Table Sort command uses the Windows Compare function.


  2. If the Windows language class is different from that used by Word, and if there is an internal sort table for the language class in Word, the Table Sort command uses the comparison functionality built into Word.


  3. If the Windows language class is different from that used by Word, and if there is no internal sort table for the language class in Word, the Table Sort command uses the Windows Compare function.


ANSI Character Sort Order - Windows Environment

The table below lists the ANSI character sort order used by WordBasic as well as the sort order used by the Sort command on the Table menu in Word for Windows.

Table Sort Command Sorting Order      WordBasic Sorting Order
====================================  ====================================
                                ANSI                                  ANSI
Character                       Code  Character                       Code
---------                       ----  ---------                       ----

(nonprinting)                     7   (nonprinting)                     1

Tab                               9   (nonprinting)                     2

Carriage return (line feed)      10   (nonprinting)                     3

Line break                       11   (nonprinting)                     4

Hard page break                  12   (nonprinting)                     5

Paragraph mark                   13   (nonprinting)                     6

Column break                     14   (nonprinting)                     7

Space                            32   (nonprinting)                     8

Nonbreaking space               160   Tab                               9

(nonprinting)                     1   Carriage return (linefeed)       10

(nonprinting)                     2   Line break                       11

(nonprinting)                     3   Hard page break                  12

(nonprinting)                     4   Paragraph mark                   13

(nonprinting)                     5   Column break                     14

(nonprinting)                     6   (nonprinting)                    15

(nonprinting)                     8   (nonprinting)                    16

(nonprinting)                    15   (nonprinting)                    17

(nonprinting)                    16   (nonprinting)                    18

(nonprinting)                    17   (nonprinting)                    19

(nonprinting)                    18   (nonprinting)                    20

(nonprinting)                    19   (nonprinting)                    21

(nonprinting)                    20   (nonprinting)                    22

(nonprinting)                    21   (nonprinting)                    23

(nonprinting)                    22   (nonprinting)                    24

(nonprinting)                    23   (nonprinting)                    25

(nonprinting)                    24   (nonprinting)                    26

(nonprinting)                    25   (nonprinting)                    27

(nonprinting)                    26   (nonprinting)                    28

(nonprinting)                    27   (nonprinting)                    29

(nonprinting)                    28   Nonbreaking hyphen               30

(nonprinting)                    29   Optional hyphen                  31

Nonbreaking hyphen               30   (nonprinting)                   128

Optional hyphen                  31   (nonprinting)                   129

(nonprinting)                   128   ‚ comma                         130

(nonprinting)                   129   Lowercase f script letter       131
                                      (function sign)

‚ comma                         130   Low double comma quotation      132
                                      mark

Lowercase f script letter       131   ... Horizontal ellipsis         133
(function sign)

Low double comma quotation      132   Dagger                          134
mark

... Horizontal ellipsis         133   Double dagger                   135

Dagger                          134   ^ spacing circumflex            136

Double dagger                   135   o/oo per mille sign             137

^ spacing circumflex            136   < Left pointing guillemet       139

o/oo per mille sign             137   (nonprinting)                   141

< Left pointing guillemet       139   (nonprinting)                   142

(nonprinting)                   141   (nonprinting)                   143

(nonprinting)                   142   (nonprinting)                   144

(nonprinting)                   143   ' Single turned comma           145
                                        quotation mark (open single
                                        smart quote)

(nonprinting)                   144   ' Single comma quotation mark   146
                                        (close single smart quote)

' Single turned comma           145   " Double turned comma           147
  quotation mark (open single           quotation mark (open double
  smart quote)                          smart quote)

' Single comma quotation mark   146   " Double comma quotation mark   148
  (close single smart quote)            (close double smart quote)

" Double turned comma           147   Bullet                          149
  quotation mark (open double
  smart quote)

" Double comma quotation mark   148   En dash                         150
  (close double smart quote)

Bullet                          149   Em dash                         151

En dash                         150   ~ Raised tilde                  152

Em dash                         151   TM Trademark                    153

~ Raised tilde                  152   > Right pointing guillemet      155

TM Trademark                    153   (nonprinting)                   157

> Right pointing guillemet      155   (nonprinting)                   158

(nonprinting)                   157   Space                            32

(nonprinting)                   158   !                                33

!                                33   "                                34

"                                34   #                                35

#                                35   $                                36

$                                36   %                                37

%                                37   &                                38

&                                38   '                                39

'                                39   (                                40

(                                40   )                                41

)                                41   *                                42

*                                42   +                                43

+                                43   ,                                44

,                                44   -                                45

-                                45   .                               46

.                               46   /                                47

/                                47   :                                58

:                                58   ;                                59

;                                59   <                                60

<                                60   =                                61

=                                61   >                                62

>                                62   ?                                63

?                                63   @                                64

@                                64   [                                91

[                                91   \                                92

\                                92   ]                                93

]                                93   ^                                94

^                                94   _                                95

_                                95   `                                96

`                                96   {                               123

{                               123   |                               124

|                               124   }                               125

}                               125   ~                               126

~                               126   (nonprinting)                   127

(nonprinting)                   127   Nonbreaking space               160

¡                               161   ¡                               161

Cent sign                       162   Cent sign                       162

British pound sign (pound       163   British pound sign (pound       163
sterling)                             sterling)

Currency sign (in Word, Table   164   Currency sign (in Word, Table   164
End-of-Cell Mark)                     End-of-Cell Mark)

Yen sign                        165   Yen sign                        165

¦                               166   ¦                               166

Section sign (double S)         167   Section sign (double S)         167

Spacing diaeresis               168   Spacing diaeresis               168

Copyright                       169   Copyright                       169

Lowercase a, superscript        170   lowercase a, superscript        170
(feminine ordinal indicator)          (Feminine ordinal indicator)

Open guillemet (<<)             171   Open guillemet (<<)             171

Not sign                        172   Not sign                        172

­ (soft hyphen)                 173   ­ (soft hyphen)                 173

Registered trademark            174   Registered trademark            174

Spacing macron (overline)       175   Spacing macron (overline)       175

Degree sign                     176   Degree sign                     176

Plus-or-minus sign              177   Plus-or-minus sign              177

Superscript 2                   178   Superscript 2                   178

Superscript 3                   179   Superscript 3                   179

Acute accent                    180   Acute accent                    180

Micro sign                      181   Micro sign                      181

Paragraph sign                  182   Paragraph sign                  182

Middle dot                      183   Middle dot                      183

Cedilla                         184   Cedilla                         184

Superscript 1                   185   Superscript 1                   185

Ring (volle) or Masculine       186   Ring (volle) or Masculine       186
ordinal indicator                     ordinal indicator

Close guillemet (>>)            187   Close guillemet (>>)            187

One-quarter fraction            188   One-quarter fraction            188

One-half fraction               189   One-half fraction               189

Three-quarters fraction         190   Three-quarters fraction         190

Inverted question mark          191   Inverted question mark          191

0                                48   0                                48

1                                49   1                                49

2                                50   2                                50

3                                51   3                                51

4                                52   4                                52

5                                53   5                                53

6                                54   6                                54

7                                55   7                                55

8                                56   8                                56

9                                57   9                                57

A                                65   A                                65

a                                97   A` Uppercase A, grave accent    192

A` Uppercase A, grave accent    192   A' Uppercase A, acute accent    193

a` Lowercase a, grave accent    224   A^ Uppercase A, circumflex      194

A' Uppercase A, acute accent    193   A~ Uppercase A, cedilla         195

a' Lowercase A, acute accent    225   A" Uppercase A, umlaut          196

A^ Uppercase A, circumflex      194   A ring Uppercase A, ring        197
                                      (volle)

a^ Lowercase A, circumflex      226   AE Uppercase AE, ligature       198

A~ Uppercase A, cedilla         195   a                                97

a~ Lowercase A, cedilla         227   a` Lowercase A, grave accent    224

A" Uppercase A, umlaut          196   a' Lowercase A, acute accent    225

a" Lowercase A, umlaut          228   a^ Lowercase A, circumflex      226

A ring Uppercase A, ring        197   a~ Lowercase A, cedilla         227
(volle)

a ring Lowercase A, ring        229   a" Lowercase A, umlaut          228
(volle)

AE Uppercase AE, ligature       198   a ring Lowercase A, ring        229
                                      (volle)

ae Lowercase AE, ligature       230   ae Lowercase AE, ligature       230

B                                66   B                                66

b                                98   b                                98

C                                67   C                                67

c                                99   C, Uppercase C, cedilla         199

C, Uppercase C, cedilla         199   c                                99

c, Lowercase C, cedilla         231   c, Lowercase C, cedilla         231

D                                68   D                                68

d                               100   D- Upper Eth                    208

D- Upper Eth                    208   d                               100

Lowercase Eth                   240   Lowercase Eth                   240

E                                69   E                                69

e                               101   E` Uppercase E, grave accent    200

E` Uppercase E, grave accent    200   E' Uppercase E, acute accent    201

e` Lowercase E, grave accent    232   E^ Uppercase E, circumflex      202

E' Uppercase E, acute accent    201   E" Uppercase E, umlaut          203

e' Lowercase E, acute accent    233   e                               101

E^ Uppercase E, circumflex      202   e` Lowercase E, grave accent    232

e^ Lowercase E, circumflex      234   e' Lowercase E, acute accent    233

E" Uppercase E, umlaut          203   e^ Lowercase E, circumflex      234

e" Lowercase E, umlaut          235   e" Lowercase E, umlaut          235

F                                70   F                                70

f                               102   f                               102

G                                71   G                                71

g                               103   g                               103

H                                72   H                                72

h                               104   h                               104

I                                73   I                                73

i                               105   I` Uppercase I, grave accent    204

I` Uppercase I, grave accent    204   I' Uppercase I, acute accent    205

i` Lowercase I, grave accent    236   I^ Uppercase I, circumflex      206

I' Uppercase I, acute accent    205   I" Uppercase I, umlaut          207

i' Lowercase I, acute accent    237   i                               105

I^ Uppercase I, circumflex      206   i` Lowercase I, grave accent    236

i^ Lowercase I, circumflex      238   i' Lowercase I, acute accent    237

I" Uppercase I, umlaut          207   i^ Lowercase I, circumflex      238

i" Lowercase I, umlaut          239   i" Lowercase I, umlaut          239

J                                74   J                                74

j                               106   j                               106

K                                75   K                                75

k                               107   k                               107

L                                76   L                                76

l                               108   l                               108

M                                77   M                                77

m                               109   m                               109

N                                78   N                                78

n                               110   n                               110

N~ Uppercase N, tilde           209   N~ Uppercase N, tilde           209

n~ Lowercase N, tilde           241   n~ Lowercase N, tilde           241

x  Multiplication sign          215   O                                79

O                                79   OE Uppercase OE, ligature       140

o                               111   O` Uppercase O, grave accent    210

OE Uppercase OE, ligature       140   O' Uppercase O, acute accent    211

oe Lowercase OE, ligature       156   O^                               212

O` Uppercase O, grave accent    210   O~ Uppercase O, tilde           213

o` Lowercase O, grave accent    242   O" Uppercase O, umlaut          214

O' Uppercase O, acute accent    211   x  Multiplication sign          215

o' Lowercase O, acute accent    243   O/ Uppercase O, slash           216

O^ Uppercase O, circumflex      212   o                               111

o^ Lowercase O, circumflex      244   oe Lowercase OE, ligature       156

O~ Uppercase O, tilde           213   o` Lowercase O, grave accent    242

o~ Lowercase O, tilde           245   o' Lowercase O, acute accent    243

O" Uppercase O, umlaut          214   o^ Lowercase O, circumflex      244

o" Lowercase O, umlaut          246   o~ Lowercase O, tilde           245

O/ Uppercase O, slash           216   o" Lowercase O, umlaut          246

o/ Lowercase O, slash           248   o/ Lowercase O, slash           248

P                                80   P                                80

p                               112   p                               112

Q                                81   Q                                81

q                               113   q                               113

R                                82   R                                82

r                               114   r                               114

S                                83   S                                83

s                               115   Sv Uppercase S hacek            138

Sv Uppercase S hacek            138   s                               115

sv Lowercase S hacek            154   sv Lowercase S hacek            154

Lowercase sharp S (ess-zed)     223   Lowercase sharp S (ess-zed)     223

T                                84   T                                84

t                               116   t                               116

U                                85   U                                85

u                               117   U` Uppercase U, grave accent    217

U` Uppercase U, grave accent    217   U' Uppercase U, acute accent    218

u` Lowercase U, grave accent    249   U^ uppercase U, circumflex      219

U' Uppercase U, acute accent    218   U" Uppercase U, umlaut          220

u' Lowercase U, acute accent    250   u                               117

U^ Uppercase U, circumflex      219   u` Lowercase U, grave accent    249

u^ Lowercase U, circumflex      251   u' Lowercase U, acute accent    250

U" Uppercase U, umlaut          220   u^ Lowercase U, circumflex      251

u" Lowercase U, umlaut          252   u" Lowercase U, umlaut          252

V                                86   V                                86

v                               118   v                               118

W                                87   W                                87

w                               119   w                               119

X                                88   X                                88

x                               120   x                               120

Y                                89   Y                                89

y                               121   Y' Uppercase Y, acute accent    221

Y' Uppercase Y, acute accent    221   Y" Uppercase Y, umlaut          159

y' Lowercase Y, acute accent    253   y                               121

Y" Uppercase Y, umlaut          159   y' Lowercase Y, acute accent    253

y" Lowercase Y, umlaut          255   y" Lowercase Y, umlaut          255

Z                                90   Z                                90

z                               122   z                               122

Uppercase Icelandic Thorn       222   Lowercase Icelandic Thorn       254

Lowercase Icelandic Thorn       254   Uppercase Icelandic Thorn       222

Division sign                   247   Division sign                   247 


REFERENCES

"Microsoft Word User's Guide," version 6.0, pages 159-161

Additional query words: winword macword expected wrong word6 sorting sorted alphanumeric symbol symbols

Keywords : kbmacroexample kbwordvba
Version : MACINTOSH:6.0,6.0.1,6.0.1a; WINDOWS:6.0,6.0a,6.0c
Platform : MACINTOSH WINDOWS
Issue type :


Last Reviewed: December 29, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.