```var aColors = ['spade','heart','diamond','club'],   //牌颜色
sCardNum = 'A123456789JQK'.split('');         //牌数字
//创建牌
function createCardObj(){
var aCard = [];
for(var i=0,c=-1;i<52;i++){
i%13 == 0 && c++;
aCard[i] = {
n: i%13,
value: sCardNum[i%13],
color: aColors[c]
}
}
return aCard;
}
//打乱牌的顺序
function shuffle( aCard ){
for(var j=aCard.length-1, nRnd, oTemp;j>=0;j--){
nRnd = Math.random()*(j+1) >> 0;
oTemp = aCard[j];
aCard[j] = aCard[nRnd];
aCard[nRnd] = oTemp;
}
return aCard;
}

//**迭代快排**
function qs(arr, fnCompare){
var stack = [];
stack.push([0,arr.length-1]);
var l,r,axis,o;
while(stack.length){
o = stack.pop();
l = o[0],r = o[1];
if( l >= r )
continue;
axis = once(arr,l,r);
stack.push([l,axis-1]);
stack.push([axis+1,r]);
}

function once(arr,l,r){
var axisAtLeft = true, //left right sign, default left;
temp;
swap(arr,l, (r+l)/2 >> 0);  //以中值为轴值
while(l<r){
if( axisAtLeft ){
if( fnCompare(arr[l],arr[r]) ){
swap(arr,l++,r);
axisAtLeft = false;
}else  r--;
}
else{
if( fnCompare(arr[l],arr[r]) ){
swap(arr,l,r--);
axisAtLeft = true;
}else  l++;
}
}
return l;
}

function swap(arr,l,r){
var temp = arr[l];
arr[l] = arr[r];
arr[r] = temp;
}
return arr;
}

function print( aCard ) {
var oColorMap = {
'heart':'#f00',
'diamond':'#900',
'club': '#777'
};
for (var k = 0; k<52; k++){
var oCurCard = aCard[k];
var  s = '<span style="color: #fff; background-color:'+ oColorMap[oCurCard.color] +'">'+ oCurCard.color+ '--'  + oCurCard.value +'</span><br/>';
document.write(s);
}
};

var card = shuffle( createCardObj() );
print( qs(card, function(o1,o2){
var mapNum = {'spade': 0,'heart': 1,'diamond': 2,'club': 3};
return  (mapNum[o1.color]*13 + o1.n)  > (mapNum[o2.color]*13 + o2.n);
}) );
```