MCPcopy Index your code
hub / github.com/subbarayudu-j/TheAlgorithms-Python / split

Method split

sorts/external-sort.py:25–40  ·  view source on GitHub ↗
(self, block_size, sort_key=None)

Source from the content-addressed store, hash-verified

23 return self.block_filenames
24
25 def split(self, block_size, sort_key=None):
26 i = 0
27 with open(self.filename) as file:
28 while True:
29 lines = file.readlines(block_size)
30
31 if lines == []:
32 break
33
34 if sort_key is None:
35 lines.sort()
36 else:
37 lines.sort(key=sort_key)
38
39 self.write_block(''.join(lines), i)
40 i += 1
41
42 def cleanup(self):
43 map(lambda f: os.remove(f), self.block_filenames)

Callers 15

sortMethod · 0.95
collect_datasetFunction · 0.80
shell_sort.pyFile · 0.80
bogosort.pyFile · 0.80
comb_sort.pyFile · 0.80
cyclesort.pyFile · 0.80
bubble_sort.pyFile · 0.80
heap_sort.pyFile · 0.80
counting_sort.pyFile · 0.80
insertion_sort.pyFile · 0.80

Calls 2

write_blockMethod · 0.95
sortMethod · 0.45

Tested by

no test coverage detected