Sorting Stuff with one Click

Hello everyone,

is in ionic a way to sort items by certain attributes (e.g. alphabet, date, number) with one click (see picture 1). I searched for a long time but only found things like “ionic-search-filter”, "Order and Grouping " etc.

It should be like in picture 1, the user clicks on “Filter” and the items contained there are sorted alphabetically. First comes “Alphabet” then “Apple” then “Beta” and then “Microsoft”.


Ionic is a UI toolkit, so the pedantic answer to your question is “no”, because what you ask is out of the scope of Ionic.

That being said, presumably your list is being displayed in the template using an ngFor directive and a backing array, so all you should need to do is to wire a (click) handler to a function in your controller that sorts the backing array as desired using Array.sort.

1 Like