Answers.Body: <p>You weren’t overlooking anything, we were :)</p>
  
  <p>We just released <a href="http://buildwithcraft.com/updates#build2616" rel="nofollow">Craft 2.3.2616</a> with four new hooks:</p>
  
  <ul>
  <li><a href="http://buildwithcraft.com/docs/plugins/hooks-reference#modifyEntrySortableAttributes" rel="nofollow">modifyEntrySortableAttributes</a></li>
  <li><a href="http://buildwithcraft.com/docs/plugins/hooks-reference#modifyCategorySortableAttributes" rel="nofollow">modifyCategorySortableAttributes</a></li>
  <li><a href="http://buildwithcraft.com/docs/plugins/hooks-reference#modifyAssetSortableAttributes" rel="nofollow">modifyAssetSortableAttributes</a></li>
  <li><a href="http://buildwithcraft.com/docs/plugins/hooks-reference#modifyUserSortableAttributes" rel="nofollow">modifyUserSortableAttributes</a></li>
  </ul>
  
  <p>That should do the trick for you.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T09:10:20.780Z
Answers.Text: Yes, that's great! Thanks Brandon. Would it be greedy if I asked for those hooks to also support a source parameter? I also wondered how to define a secondary sort key for each attribute, is this possible?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T10:45:35.517Z
Answers.Text: @carlcs The source is not known when element types' defineSortableAttributes() is called; it's only called once, on the initial page load, and the options don't change when changing sources. (The only exception to that is, the JS will add the "Structure" option in dynamically when a structured source is selected.) Not sure what you mean by a "secondary source key for each attribute"?
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T10:54:33.437Z
Answers.Text: I meant a secondary key that you can sort by, if the primary values were the same (e.g. sort by lightswitch field and then by datetime field).
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T11:01:49.573Z
Answers.Text: Thanks so far, but I hope you find a working solution to define sortableAttributes per source. I think this is essential to the whole functionality (I don't want the Client to be able to sort the "Blog" structure by "Opening Time" for example).
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T12:43:31.317Z
Answers.Text: @carlcs The keys you add will be passed directly into the `order` parameter, so you can juts throw a comma in the array key.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T13:05:31.897Z
Answers.Text: I tried this, but it doesn't work. It doesn't throw any PHP errors, but I can't click the option in the dropdown. You mean like this `$attributes['exhibitionPlace,releaseDate desc']`, right? The same string works in an ElementCriteriaModel in my template though!
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T13:42:55.447Z
Answers.Text: @carlcs Yes that’s what I meant, but there were a couple bugs preventing that form working as expected. Just fixed that for the next release.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-03T22:30:35.613Z
Answers.LastActivityDate: 2014-12-03T22:30:35.613Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Good chance this is more of a feature request than a question you can help out. But as I am new to Craft plugin development and might oversee something I ask it anyways:</p>
  
  <p>Now that it is possible to customize the index pages in the CP using the plugin hooks <a href="http://buildwithcraft.com/docs/plugins/hooks-reference#modifyEntryTableAttributes" rel="nofollow noreferrer"><code>modifyEntryTableAttributes</code></a> and <a href="http://buildwithcraft.com/docs/plugins/hooks-reference#getEntryTableAttributeHtml" rel="nofollow noreferrer"><code>getEntryTableAttributeHtml</code></a>, what do I have to do to make my custom columns appear in the sort order dropdown / make the entries sortable by my new columns?</p>
  
Tags: <plugin-development><control-panel>
Title: Set custom sort order for index pages in the CP?
ThreadText: # Set custom sort order for index pages in the CP?
  
  (Asked by: username_0 on 2014-12-02)
  
  Good chance this is more of a feature request than a question you can help out. But as I am new to Craft plugin development and might oversee something I ask it anyways:
  
  Now that it is possible to customize the index pages in the CP using the plugin hooks [`modifyEntryTableAttributes`](http://buildwithcraft.com/docs/plugins/hooks-reference#modifyEntryTableAttributes) and [`getEntryTableAttributeHtml`](http://buildwithcraft.com/docs/plugins/hooks-reference#getEntryTableAttributeHtml), what do I have to do to make my custom columns appear in the sort order dropdown / make the entries sortable by my new columns?
  
  **Tags:** plugin-development, control-panel
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-12-03. Score: 2 | Accepted answer
  
  You weren’t overlooking anything, we were :)
  
  We just released [Craft 2.3.2616](http://buildwithcraft.com/updates#build2616) with four new hooks:
  
  * [modifyEntrySortableAttributes](http://buildwithcraft.com/docs/plugins/hooks-reference#modifyEntrySortableAttributes)
  * [modifyCategorySortableAttributes](http://buildwithcraft.com/docs/plugins/hooks-reference#modifyCategorySortableAttributes)
  * [modifyAssetSortableAttributes](http://buildwithcraft.com/docs/plugins/hooks-reference#modifyAssetSortableAttributes)
  * [modifyUserSortableAttributes](http://buildwithcraft.com/docs/plugins/hooks-reference#modifyUserSortableAttributes)
  
  That should do the trick for you.
  
  > **Comments:**
  > **username_0**: Yes, that's great! Thanks username_1. Would it be greedy if I asked for those hooks to also support a source parameter? I also wondered how to define a secondary sort key for each attribute, is this possible?  
  > **username_1**: @username_0 The source is not known when element types' defineSortableAttributes() is called; it's only called once, on the initial page load, and the options don't change when changing sources. (The only exception to that is, the JS will add the "Structure" option in dynamically when a structured source is selected.) Not sure what you mean by a "secondary source key for each attribute"?  
  > **username_0**: I meant a secondary key that you can sort by, if the primary values were the same (e.g. sort by lightswitch field and then by datetime field).  
  > **username_0**: Thanks so far, but I hope you find a working solution to define sortableAttributes per source. I think this is essential to the whole functionality (I don't want the Client to be able to sort the "Blog" structure by "Opening Time" for example).  
  > **username_1**: @username_0 The keys you add will be passed directly into the `order` parameter, so you can juts throw a comma in the array key.  
  > **username_0**: I tried this, but it doesn't work. It doesn't throw any PHP errors, but I can't click the option in the dropdown. You mean like this `$attributes['exhibitionPlace,releaseDate desc']`, right? The same string works in an ElementCriteriaModel in my template though!  
  > **username_1**: @username_0 Yes that’s what I meant, but there were a couple bugs preventing that form working as expected. Just fixed that for the next release.  
  
  ---
  
  