I was working on a Python program recently and I needed to sort a NumPy array-of-arrays based on one of the columns. For example, if the data is:
[[10. 13. 15.] [19. 11. 14.] [15. 17. 12.] [14. 12. 18.]]
and I want to sort based on the middle column values, the desired result is:
[[19. 11. 14.] [14. 12. 18.] [10. 13. 15.] [15. 17. 12.]]
There are several ways to do this. After some experimentation, I liked this approach:
data = np.array( # set up data ) ordering = data[:,1].argsort() # gives [1,3,0,2] sorted_data = data[ordering]
The [:,1] means “all rows, just column [1]”. The weirdly-named argsort() function uses quicksort and returns the indices of the sorted data. Supplying that result into data is a Python idiom to give the sorted data.
OK, no big deal. Will I remember this little coding trick? No, because it will probably be months before I need to use the trick again.
While I was figuring out this micro-problem, I was reminded of a job interview I had once. The interviewer asked me how to select n random items from N items, for example select 3 items from a list of 10 items. My answer was that in most cases I’d use the Reservoir Sampling algorithm, which is what the interviewer was looking for. (As opposed to a crude approach of shuffling all N items, then extracting the first n items).
Then the interviewer asked me to explain how the Reservoir Sampling algorithm works and I explained that you start with the first n indices, such as (0,1,2) and then iterate from 4 to N and either make an exchange or not (which is correct). But then the interviewer asked me to code an example, so I used pseudo-code and explained that I didn’t remember the exact implementation details because I recalled that implementation is quite tricky, and if I ever needed to code it up, I’d look up my notes.
This didn’t sit well with the interviewer. I could tell he wanted me to code up the answer exactly, which I certainly could have done but it would have taken 10 minutes. But in my mind I had answered correctly, and seeing an implementation wasn’t the point of the interview question. To keep the interviewer happy, I coded up a solution using the C# language.
I don’t memorize the details of most algorithms. Instead, I remember what algorithms can be used to solve each type of problem, and the general approach of the algorithm because I can always look up the details quickly.
Albert Einstein didn’t know his own phone number and had it written down on a piece of paper. He explained that he never memorized things he could just look up.
I’m no Einstein of course but seeing how the interviewer didn’t grasp this idea made me feel like working in his group would be bad chemistry. I got a job offer from the group but I declined the offer, entirely because of that interview experience. I live in a world of math, logic, and technology but human intuition is still very important.

The Internet is endlessly interesting. Here are five images that were returned by an image search for “bad chemistry”. Most make sense in some way, but the middle image seems out of place.

.NET Test Automation Recipes
Software Testing
SciPy Programming Succinctly
Keras Succinctly
R Programming
2026 Visual Studio Live
2025 Summer MLADS Conference
2026 DevIntersection Conference
2025 Machine Learning Week
2025 Ai4 Conference
2026 G2E Conference
2026 iSC West Conference
You must be logged in to post a comment.