Today I was trying to a list of of AD computer objects to group them by OU. The obvious way was to try sorting by distinguishedname. But sorting is simply alphabetical and so it is simply a sort by the computer name since that is listed first
CN=RTC119Test,OU=Testing,DC=mydomain,DC=com
Then I tried canonicalname and got results I could use
mydomain.com/Testing/RTC119Test
Here is the Powershell I used
get-adcomputer -filter * -properties operatingsystem,canonicalName|select name,operatingsystem,canonicalName,distinguishedname|sort canonicalName|ft
Note: You must specify "-properties canonicalname" to force the server to return the canonicalname property so you can use it.