protect sorting function.