Sort visitors from a custom variable

Hello, i have set a custom variable that tracks the username of a visitor. Piwik tracks unique visitors and returning visitors by the ip.
Is it possible to sort the users by my custom variable and not the ip?
To be more specific i have this

 _paq.push(['setCustomVariable',1,"user",{{ app.user.username|json_encode|raw }},"visit"]);

and i want it to be the sorting method and if its possible to be like an primary key at the database.
Thank you in advance.
P.S. Sorry for my poor English.

What do you mean by “sorting method” and “sort the users” ?