Improve reorder implementation for AMatrix