title: Ordering by complex types in Azure Search .NET SDK?
body: <p>So I have an index built with a parent/child structure like follows:</p>
  <pre><code>    {
              &quot;Id&quot;: &quot;13704&quot;,
              &quot;StreetNumber&quot;: &quot;29&quot;,
              &quot;StreetName&quot;: &quot;Fiction Road&quot;,
              &quot;PostalCode&quot;: &quot;DD1 G33&quot;
              &quot;CityName&quot;: &quot;Fiction City&quot;,
              &quot;Property&quot;: {
                  &quot;ID&quot;: 13592,
                  &quot;ParentPropertyID&quot;: 123
              }
      }
  </code></pre>
  <p>I want to order by Property/ParentPropertyID, which works fine on the Azure Portal using the following query string:</p>
  <pre><code>search=DD1 G33&amp;searchmode=all&amp;$orderby=Property/ParentPropertyID asc
  </code></pre>
  <p>This works as expected, and returns me a list of records matching this postcode ordered as specified. But, when I try to do this in C# with the Azure Search SDK, it returns results but doesn't seem to apply the order by. If I use one of the parent fields (e.g. StreetNumber) instead, it does work, so it seems limited to complex types. Code:</p>
  <pre><code>            SearchParameters parameters;
              DocumentSearchResult&lt;TempAddress&gt; results;
  
              parameters =
                  new SearchParameters()
                  {
                      SearchMode = SearchMode.All,
                      OrderBy = new[] { &quot;Property/ParentPropertyID asc&quot; }
                  };
  
              results = _searchIndexClient.Documents.Search&lt;TempAddress&gt;(&quot;DD1 G33&quot;, parameters);
  </code></pre>
  <p>The results object returns the list of correct results, but the OrderBy hasn't been applied. It seems to find the field without any issues as it doesn't throw any errors. I can't really seem to find any examples of ordering by complex types either, or any examples involving complex types is using the same syntax as I've used above (i.e. ParentProp/ChildProp). If I change</p>
  <pre><code>OrderBy = new[] { &quot;Property/ParentPropertyID asc&quot; }
  </code></pre>
  <p>to:</p>
  <pre><code>OrderBy = new[] { &quot;StreetNumber desc&quot; }
  </code></pre>
  <p>The OrderBy works with no problems. I can't really see why this isn't working in code, but works on the portal?</p>