Added templatized routine for selection sort