Components.utils.import("resource://gre/modules/Services.jsm");
var gBrowser = Services.wm.getMostRecentWindow("navigator:browser").gBrowser;
var tabs = [];
for (var i = 0; i < gBrowser.tabs.length - 1; i++){
tabs[i] = gBrowser.tabs[i];
}
tabs.sort(
function(a, b)(
(a.linkedBrowser.currentURI.asciiSpec < b.linkedBrowser.currentURI.asciiSpec) ? -1 : 1
)
);
tabs.forEach(gBrowser.moveTabTo.bind(gBrowser));