# Setting sortedProperty

**URL:** https://discuss.emberjs.com/t/setting-sortedproperty/9229
**Category:** Uncategorized
**Created:** [December 2, 2015, 5:29am UTC](https://discuss.emberjs.com/t/setting-sortedproperty/9229 "2015-12-02T05:29:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![celo](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@celo](https://discuss.emberjs.com/u/celo)
#### Post date: [December 2, 2015, 5:29am UTC](https://discuss.emberjs.com/t/setting-sortedproperty/9229/1 "2015-12-02T05:29:29Z")

</div>

I’m trying to sort my date if the user clicks in a , but is not working well. That’s the code:

Inside my table header i have:

```
            <th class="tables__th" {{action "sortBy" "name"}}>Nome</th>
            <th class="tables__th" {{action "sortBy" "date"}}>Data</th>
            <th class="tables__th" {{action "sortBy" "bookings"}}>Reservas</th>

```

And in the controller i have:

```
export default Ember.Controller.extend(PcCheckbox, PcRequest, {
  requestName: 'Evento',
  query: '',

  /*
   *
   * Default sort properties
   */
  sortAscending: true,
  sortProperty: 'date',

  actions: {
    sortBy(propertyKey) {
      if (propertyKey === this.get('sortProperty')) {
        this.toggleProperty('sortAscending');
      }

      this.set('sortProperty', propertyKey);
    }
  }
});

```

Shouldn’t this by enough??

Thanks.
