你这种排序做起来比较麻烦
看看这里的文章,是在mysql上实现的方法http://blog.chinaunix.net/u/29134/showart_439264.html