bubble sorting with template