<p>I've got an array of <code>char*</code> in a file. 
The company I work for stores data in flat files.. Sometimes the data is sorted, but sometimes it's not. 
I'd like to sort the data in the files.</p>

<p>Now I could write the code to do this, from scratch. 
Is there an easier way? </p>

<p>Of course an in-place sort would be the best option. I'm working on large files and have little RAM. But I'll consider all options. </p>

<p>All strings are the same length. </p>

<p>This is some sample data:</p>

<pre><code>the data is of fixed length
the Data is of fixed length
thIS data is of fixed lengt
</code></pre>

<p>This would represent three records of length 28. The app knows the length. Each record ends with CRLF (<code>\r\n</code>), though it shouldn't matter for this sort. </p>

```
```
template<size_t length> int less(const char* left, const char* right) {
    return memcmp(left, right, length) < 0;
}

std::sort(array, array + array_length, less<buffer_length>);
```
```