Sorts chunks into array of scripts.
@param {Array} chunks
483761
function getScripts(chunks) {
  let scripts = [];

  // Used when skipping the build, short-circuit to return metadata
  if (chunks.metadata) {
    return chunks.metadata;
  }

  sorter.dependency(chunks).forEach((chunk) => {
    scripts.push({
      name: chunk.files[0]
    });
  });

  return scripts;
}
1238815
function(n_newlines) {
				if('number' === typeof n_newlines) {
					for(let i=0; i<n_newlines; i++) {
						a_chunks.push('');
					}
				}
				else {
					a_chunks.push('');
				}
			}
262078
function reset() {
          splitOnChars = opt.splitOnChars.slice(0);
          splitChar = splitOnChars[0];
          chunks = null;
          lastChunk = null;
        }
1368515
function(segments) {
        var previousSegment = [-1, -1];
        var segmentIndicesToRemove = [];
        var cleanedSegmentArray = [];
        var i, ii;
        for (i = 0, ii = segments.length; i < ii; ++i) {
            if (!(previousSegment[0] <= segments[i][0] &&
                    previousSegment[1] >= segments[i][1])) {
                cleanedSegmentArray.push(segments[i]);
            }
            previousSegment = segments[i];
        }

        segments.length = 0;
        for (i = 0, ii = cleanedSegmentArray.length; i < ii; ++i) {
            segments.push(cleanedSegmentArray[i]);
        }
    }
1301623
function ChunkedStreamManager_groupChunks(chunks) {
      var groupedChunks = [];
      var beginChunk = -1;
      var prevChunk = -1;
      for (var i = 0; i < chunks.length; ++i) {
        var chunk = chunks[i];

        if (beginChunk < 0) {
          beginChunk = chunk;
        }

        if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
          groupedChunks.push({ beginChunk: beginChunk,
                               endChunk: prevChunk + 1 });
          beginChunk = chunk;
        }
        if (i + 1 === chunks.length) {
          groupedChunks.push({ beginChunk: beginChunk,
                               endChunk: chunk + 1 });
        }

        prevChunk = chunk;
      }
      return groupedChunks;
    }
653330
function arrayShuffle (array) {
  var index
  var result = []
  var list = baseExports.values(array)
  var len = list.length - 1
  for (; len >= 0; len--) {
    index = len > 0 ? XEUtils.random(0, len) : 0
    result.push(list[index])
    list.splice(index, 1)
  }
  return result
}
1083227
def partition_scripts(scripts, start_type1, start_type2):
    
    match, other = [], []
    for script in scripts:
        if (HairballPlugin.script_start_type(script) == start_type1 or 
            HairballPlugin.script_start_type(script) == start_type2):
            match.append(script)
        else:
            other.append(script)
    return match, other
9852
public static void insertSort(int[] arrays) {
        for (int i = 1; i < arrays.length; i++) {
            int currentNumber = arrays[i];
            int j = i - 1;
            while (j >= 0 && arrays[j] > currentNumber) {
                arrays[j + 1] = arrays[j--];
            }
            arrays[j + 1] = currentNumber;
        }
    }
691702
function highlightMatches(chunks) {
    return $.map(chunks, function (chunk) {
        var text = utils.escapeHtml(chunk.text);

        if (text && chunk.matched) {
            text = '<strong>' + text + '</strong>';
        }
        return text;
    }).join('');
}
857540
private void removeCoord(Chunk chunk, BlockPos pos)
	{
		chunks(chunk).remove(chunk, pos);
	}
693203
function sortIndexes(indexes, sort) {
	function compare(a, b) {
		return a > b ? -1 : (b > a ? 1 : 0);
	}

	// format: [{ name: 'colName', direction: 'asc' }, { name: 'colName2', direction: 'desc' }]
	// direction is 'asc' by default

	indexes.sort(function (a, b) {
		var result = 0;

		for (var i = 0; i < sort.length && result === 0; i++) {
			var prop = sort[i].name;
			var factor = sort[i].direction === 'desc' ? -1 : 1;

			result = factor * compare(a[prop], b[prop]);
		}

		return result;
	});
}
276365
private void sort() {
        RangeHashSorter sortMachine;
        sortMachine = new RangeHashSorter(maxRangeValues, filenames);
        sortMachine.quickSort();
        generateBucketIds();
    }
1219712
function mergeScripts(crsScripts) {
  const scripts = {
    build: path.join(__dirname, 'scripts/build.js'),
    start: path.join(__dirname, 'scripts/start.js'),
    test: path.join(__dirname, 'scripts/test.js'),
  };
  crsScripts.forEach(scriptSet => {
    Object.assign(scripts, scriptSet || {});
  });
  return scripts;
}
1221947
def swap(self, old_chunks, new_chunk):
    
    indexes = [self.index(chunk) for chunk in old_chunks]
    del self[indexes[0]:indexes[-1] + 1]
    self.insert(indexes[0], new_chunk)
339217
public static void selectSort(int[] arrays) {
        for (int i = 0; i < arrays.length; i++) {
            int lowIndex = i;
            for (int j = i + 1; j < arrays.length; j++) {
                if (arrays[j] < arrays[lowIndex]) {
                    lowIndex = j;
                }
            }
            if (lowIndex != i) {
                switchNumber(arrays, i, lowIndex);
            }
        }
    }
452444
def clean_up(scripts):
    
    scripts_with_pos = [s for s in scripts if s.pos]
    scripts_with_pos.sort(key=lambda s: (s.pos[1], s.pos[0]))
    scripts = scripts_with_pos + [s for s in scripts if not s.pos]

    y = 20
    for script in scripts:
        script.pos = (20, y)
        if isinstance(script, kurt.Script):
            y += stack_height(script.blocks)
        elif isinstance(script, kurt.Comment):
            y += 14
        y += 15
655124
function createChunkCache(chunks, capacity)
{
  var chunkCache;
  var onLoadComplete;
  var index;
  var length;

  // create a chunk cache
  chunkCache = new ChunkCache(capacity);

  // every time a chunk is loaded, add it to the cache
  // TODO: should the caching be based on most recently 'used' or most recently
  // 'loaded'?
  onLoadComplete = function(err, chunk)
  {
    if (!err)
    {
      chunkCache.put(chunk);
    }
  };

  // subscribe to the 'loadcomplete' event on all the chunks
  for (index = 0, length = chunks.length; index < length; index++)
  {
    chunks[index].on('loadcomplete', onLoadComplete);
  }

  // TODO: do we need to unsubscribe from the loadcomplete event at some point?

  return chunkCache;
}