# Is there any way to sort virtual field?

**URL:** <https://discourse.cakephp.org/t/is-there-any-way-to-sort-virtual-field/3557>\
**Category:** Need Help\
**Created:** [November 22, 2017, 11:11pm UTC](https://discourse.cakephp.org/t/is-there-any-way-to-sort-virtual-field/3557 "2017-11-22T23:11:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thost.co.il](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@Thost.co.il](https://discourse.cakephp.org/u/Thost.co.il)\
**Post date:** [November 22, 2017, 11:11pm UTC](https://discourse.cakephp.org/t/is-there-any-way-to-sort-virtual-field/3557/1 "2017-11-22T23:11:15Z")

</div>

hello,

i need to count user logins from login table by user id.  
i make virtual field in user that count and show, how i can make it sort on table view ?

thanks.

---

<div class="post-metadata">

**Author:** ![jarekgol](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jarekgol](https://discourse.cakephp.org/u/jarekgol)\
**Post date:** [November 22, 2017, 11:19pm UTC](https://discourse.cakephp.org/t/is-there-any-way-to-sort-virtual-field/3557/2 "2017-11-22T23:19:37Z")

</div>

php sort array functions or manually with foreach

---

<div class="post-metadata">

**Author:** ![Thost.co.il](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@Thost.co.il](https://discourse.cakephp.org/u/Thost.co.il)\
**Post date:** [November 23, 2017, 12:12am UTC](https://discourse.cakephp.org/t/is-there-any-way-to-sort-virtual-field/3557/3 "2017-11-23T00:12:12Z")

</div>

i want to sort it on the view table.
