implement sorted writing in simplethreadpoolbamdecode