Button that toggles sort by mode?

I'd like to add a button on the toolbar that toggles the sort by mode:
[ul]
[li]if the mode is currently sort by filename then clicking the button should change the mode to sort by filetype[/li]
[li]if the mode is currently anything else then clicking the button should change the mode to sort by filename[/li][/ul]

Is that possible? And if so, how? I can't even find a basic sort by option in the list of commands when I customise the toolbar.

Thank you :smiley:

@ifset:SORTBY=type Set SORTBY=name @ifset:else Set SORTBY=type

Perfect!

Thank you leo, it's greatly appreciated. :smiley: