Abstract sort testing to single function

This allows many sorting methods to be tested easily
Include stdio.h in shuffle

Required for snprintf
Fix out of bounds access in shuffle
Add a naive implementation of bubble sort