Is there way to sort tabs in Firefox? That is, given a set of tabs, press a button to sort a group of tabs (e.g., by url). It shouldn't be always sorted, only when the button is pressed. Also, it'd be helpful if a subset of tabs could be specified.
However, you might be interested in using the "Tab Groups" feature, which lets you organize your tabs, manually, into multiple groups between which you can switch. To use this feature, click the tab group button (four rectangles) at the far right of the tab bar (alternatively, hit command-shift-E on Mac or control-shift-E on Windows/Linux).
You can read more here.
There is the Sort Tabs add-on - not as powerful as what you described, but it's better than nothing. Allows to sort tabs by title, works very well for me.