# Implementing name sorts

**URL:** <https://discourse.citationstyles.org/t/implementing-name-sorts/743>\
**Category:** CSL Development\
**Created:** [August 24, 2009, 11:50pm UTC](https://discourse.citationstyles.org/t/implementing-name-sorts/743 "2009-08-24T23:50:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Bennett](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/frank_bennett/32/198_2.png) [@Frank\_Bennett](https://discourse.citationstyles.org/u/Frank_Bennett)\
**Post date:** [August 24, 2009, 11:50pm UTC](https://discourse.citationstyles.org/t/implementing-name-sorts/743/1 "2009-08-24T23:50:42Z")

</div>

Thinking about setting up some systematic tests of name sorting, and I  
have a question.

Macros are normally used as the sort key for a name, to take advantage  
of substitution, but macros may not display the name in the order to  
be used in sort keys. So I’m wondering whether name-as-sort-order  
should be forced to “all” when a name is processed to generate a sort  
key.

Put another way, are there any cases in which names should be sorted  
given-name first?

I can’t think of any such cases, and if it’s safe to force names into  
the correct order for sorting when building a key, it would make  
things a lot more foolproof for designers. Maybe this is the way  
things work already in Zotero – I don’t know.

(I see that there are some styles in the repository that use . I assume that the individual names of which the  
variable is composed should be delivered in sort order in this case –  
I don’t think citeproc-js handles this yet, but I’ll fix it up along  
with the rest of the name sorting stuff when I get there.)

Frank

---

<div class="post-metadata">

**Author:** ![Bruce\_D\_Arcus1](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Bruce\_D\_Arcus1](https://discourse.citationstyles.org/u/Bruce_D_Arcus1)\
**Post date:** [August 25, 2009, 12:28am UTC](https://discourse.citationstyles.org/t/implementing-name-sorts/743/2 "2009-08-25T00:28:09Z")

</div>

> Thinking about setting up some systematic tests of name sorting, and I  
> have a question.
> 
> Macros are normally used as the sort key for a name, to take advantage  
> of substitution,

Correct.

> but macros may not display the name in the order to  
> be used in sort keys. So I’m wondering whether name-as-sort-order  
> should be forced to “all” when a name is processed to generate a sort  
> key.

Effectively, yes, but I’d go farther I think. For example, if et-al is  
in effect, that also isn’t included in the sort string. I’d think of a  
normalized string constructed specifically for sorting?

wall:jane;king:samuel;smith:david

> Put another way, are there any cases in which names should be sorted  
> given-name first?

Only if there’s no family name.

> I can’t think of any such cases, and if it’s safe to force names into  
> the correct order for sorting when building a key, it would make  
> things a lot more foolproof for designers. Maybe this is the way  
> things work already in Zotero – I don’t know.

What I describe above is how my XSLT code works.

Bruce

---

<div class="post-metadata">

**Author:** ![Frank\_Bennett](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/frank_bennett/32/198_2.png) [@Frank\_Bennett](https://discourse.citationstyles.org/u/Frank_Bennett)\
**Post date:** [August 25, 2009, 12:42am UTC](https://discourse.citationstyles.org/t/implementing-name-sorts/743/3 "2009-08-25T00:42:27Z")

</div>

> > Thinking about setting up some systematic tests of name sorting, and I  
> > have a question.
> > 
> > Macros are normally used as the sort key for a name, to take advantage  
> > of substitution,
> 
> Correct.
> 
> > but macros may not display the name in the order to  
> > be used in sort keys. So I’m wondering whether name-as-sort-order  
> > should be forced to “all” when a name is processed to generate a sort  
> > key.
> 
> Effectively, yes, but I’d go farther I think. For example, if et-al is  
> in effect, that also isn’t included in the sort string. I’d think of a  
> normalized string constructed specifically for sorting?
> 
> wall:jane;king:samuel;smith:david

Right. I think that’s mentioned in the spec, actually.

> > Put another way, are there any cases in which names should be sorted  
> > given-name first?
> 
> Only if there’s no family name.
> 
> > I can’t think of any such cases, and if it’s safe to force names into  
> > the correct order for sorting when building a key, it would make  
> > things a lot more foolproof for designers. Maybe this is the way  
> > things work already in Zotero – I don’t know.
> 
> What I describe above is how my XSLT code works.

Very good, looks like this squared away, then. Just needs testing and  
coding, time permitting.
