UV scripts

there is a script that i am having difficulty with, it aligns the selected UV's to the max U or the min U and dose the same thing for V as well there 4 different buttons but have the same basic function.