title: Ctypes Return Array
body: <p>I'm trying to have a python wrapper for an array sort function in C.  The C takes the array, sorts the integers by smallest to largest, then returns the array.  But when I run it however, I get error:<br>
  </p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "sortarray.py", line 25, in &lt;module&gt;
      newarray = sortArray(array)
    File "sortarray.py", line 8, in sortArray
      libsortarray.sortArray.argtypes = (ctypes.c_int, ctypes.POINTER(ctypes.c_int))
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
      func = self.__getitem__(name)
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
      func = self._FuncPtr((name_or_ordinal, self))
  AttributeError: dlsym(0x7f84484280e0, sortArray): symbol not found
  </code></pre>
  
  <p>Python:
  </p>
  
  <pre class="lang-python prettyprint-override"><code>import ctypes
  
  libsortarray = ctypes.CDLL('libsortarray.so')
  
  def sortArray(array):
      global libsortarray
      libsortarray.sortArray.argtypes = (ctypes.c_int, ctypes.POINTER(ctypes.c_int))
      arraySize = len(array)
      array_type = ctypes.c_int * arraySize
      result = libsortarray.sortArray(ctypes.c_int(arraySize), array_type(*array))
      return result
  
  
  file = open('bigarray.txt', 'r')
  #Bigarray.txt is just 10,000 lines each with a single integer
  array = []
  arraySize = 10000
  for i in range(0,arraySize):
      array.append(int(file.readline()))
  file.close()
  
  newarray = sortArray(array)
  print newarray
  </code></pre>
  
  <p>And the libsortarray function
  </p>
  
  <pre class="lang-c prettyprint-override"><code>int* sortArray(int, int*);
  
  int* sortArray(int arraySize, int* array) {
      int temp, i, j;
      for (i=0; i&lt;arraySize; i++)
          for (j=i+1; j&lt;arraySize; j++)
              if (array[i] &gt; array[j]) {
                  temp = array[i];
                  array[i] = array[j];
                  array[j] = temp;
              }
      return array;
  }
  </code></pre>