code: function painterSortStable ( a, b ) {
  
  		if ( a.material.id !== b.material.id ) {
  
  			return b.material.id - a.material.id;
  
  		} else if ( a.z !== b.z ) {
  
  			return b.z - a.z;
  
  		} else {
  
  			return a.id - b.id;
  
  		}
  
  	}
docs: Sorting