When I output the terms in a term store, the first level terms are sorted alphabetically but the second level sub terms are not sorted. According to http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.term.terms.aspx the TermCollection returned by Term.Terms should be alpha sorted. I have verified that the Custom Sort is not set (ie. use default sort order). For example, my output is:
Codes and Standards
--Organizations
Database Management
--Oracle
--SQL Server
Development
--Windows 7
--Business Rules
--Content Management
--Customer Support
--Developer Tips
--Internal Documentation
--Mobile
--Performance
--Testing
--Third Party Tools
--Utilities
--Visual Studio
--Database
What's wrong with this? Here's the code:
$session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession("http://server1")
$termstore = $session.TermStores[0]
$termSet = $termStore.GetTermSet("5d73591d-b25e-4b06-838d-df8b42aac762")
foreach ($term in $termSet.Terms)
{
#Only output alpha sorted terms
if ($term.CustomSortOrder -eq $NULL)
{
$term.Name
foreach ($subterm in $term.Terms)
{
"--" + $subterm.Name
}
}
}