MCPcopy Index your code
hub / github.com/plotly/plotly.js / compareCells

Function compareCells

stackgl_modules/index.js:9668–9713  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

9666}
9667
9668function compareCells(a, b) {
9669 var n = a.length
9670 , t = a.length - b.length
9671 if(t) {
9672 return t
9673 }
9674 switch(n) {
9675 case 0:
9676 return 0
9677 case 1:
9678 return a[0] - b[0]
9679 case 2:
9680 return (a[0]+a[1]-b[0]-b[1]) ||
9681 min(a[0],a[1]) - min(b[0],b[1])
9682 case 3:
9683 var l1 = a[0]+a[1]
9684 , m1 = b[0]+b[1]
9685 t = l1+a[2] - (m1+b[2])
9686 if(t) {
9687 return t
9688 }
9689 var l0 = min(a[0], a[1])
9690 , m0 = min(b[0], b[1])
9691 return min(l0, a[2]) - min(m0, b[2]) ||
9692 min(l0+a[2], l1) - min(m0+b[2], m1)
9693 case 4:
9694 var aw=a[0], ax=a[1], ay=a[2], az=a[3]
9695 , bw=b[0], bx=b[1], by=b[2], bz=b[3]
9696 return (aw+ax+ay+az)-(bw+bx+by+bz) ||
9697 min(aw,ax,ay,az)-min(bw,bx,by,bz,bw) ||
9698 min(aw+ax,aw+ay,aw+az,ax+ay,ax+az,ay+az) -
9699 min(bw+bx,bw+by,bw+bz,bx+by,bx+bz,by+bz) ||
9700 min(aw+ax+ay,aw+ax+az,aw+ay+az,ax+ay+az) -
9701 min(bw+bx+by,bw+bx+bz,bw+by+bz,bx+by+bz)
9702 default:
9703 var as = a.slice().sort(compareInt)
9704 var bs = b.slice().sort(compareInt)
9705 for(var i=0; i<n; ++i) {
9706 t = as[i] - bs[i]
9707 if(t) {
9708 return t
9709 }
9710 }
9711 return 0
9712 }
9713}
9714
9715
9716/***/ }),

Callers 5

compareOrientedCellsFunction · 0.85
compareZippedFunction · 0.85
uniqueFunction · 0.85
findCellFunction · 0.85
incidenceFunction · 0.85

Calls 1

minFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…