I wasn't happy with that part of the request.  You could probably more cleanly do that with the cartridge sort order - see how web frameworks are handled today.