27 lines
518 B
Python
27 lines
518 B
Python
import ctypes
|
|
import sys
|
|
|
|
|
|
if sys.platform.startswith('win'):
|
|
_mslib = ctypes.CDLL('libms.dll')
|
|
else:
|
|
_mslib = ctypes.CDLL('libms.so')
|
|
|
|
|
|
def mergesort(arr):
|
|
size = len(arr)
|
|
IntArr = ctypes.c_int * size
|
|
x = IntArr(*arr)
|
|
foo = _mslib.mymergesort(x, size)
|
|
del arr[:]
|
|
arr.extend(x)
|
|
return foo
|
|
|
|
def mergesortp(arr, cnt):
|
|
size = len(arr)
|
|
IntArr = ctypes.c_int * size
|
|
x = IntArr(*arr)
|
|
foo = _mslib.mymergesortp(x, size, cnt)
|
|
del arr[:]
|
|
arr.extend(x)
|
|
return foo
|