optimized bw_encode to work a lot faster if the default order is a
generic one