implement suffix array algorithm