Question: I'm trying to make a C++ library available as a Python module. It seems SIP is the best tool for the job. (If wrong, please correct me.)

One class looks like the programmer was trying to get around c's lack of dynamic typing:

```
class Item{
  private:
    enum ITEMTYPE{TYPE_INT,TYPE_FLOAT,TYPE_INT_ARRAY,TYPE_FLOAT_ARRAY};
    enum ITEMTYPE type;
    int intValue;
    int* intArrayValue;
    float floatValue;
    float* floatArrayValue;
  public:
    enum ITEMTYPE getType();
    int getItemCount();
    int getIntValue();
    int* getIntArrayValue();
    float getFloatValue();
    float* getFloatArrayValue();
    ...
};

```

I can't find documentation anywhere that says how to handle functions that return arrays. At minimum, I'd like to be able to call getIntArrayValue() from Python. Even better would be to have a single Python function that automatically calls getType(), then calls one of the get???Value() to get the value (and if necessary, calls getItemCount() to determine the array length, treating arrays as numpy or tuples.

My current .sil file looks like this:

```
class Item{
%TypeHeaderCode
#include<Item.h>
%End
public:
  enum ITEMTYPE{
    TYPE_INT=0,
    TYPE_FLOAT=1,
    TYPE_INT_ARRAY=2,
    TYPE_FLOAT_ARRAY=3,
  };
  ITEMTYPE getType();
  int getItemCount();
  int getIntValue();
//int*getIntArrayValue();
  float getFloatValue();
//float*getFloatArrayValue();
};

```

Thanks in advance. I've been searching so hard, but have come up empty.

Answer: 
There are 26 characters, So you can use [`counting sort`](http://en.wikipedia.org/wiki/Counting_sort) to sort them, in your counting sort you can have an index which determines when specific character visited first time to save order of occurrence. [They can be sorted by their count and their occurrence with sort like radix sort].

**Edit:** by words first thing every one can think about it, is using Hash table and insert words in hash, and in this way count them, and They can be sorted in O(n), because all numbers are within 1..n steel you can sort them by counting sort in O(n), also for their occurrence you can traverse string and change position of same values.
It's a reference to [Big O notation](https://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o). Basically the interviewer means that you have to complete the task with an O(N) algorithm.