That is very difficult task on any mesh which is not topologically mixed orhas multiple island. For primitive shapes, or topologically simple (quads only) it can be done. Probably the best bet is to check edge angles agains major axis with threshold. Alternatively, you can start with any point, find closest points and select the ones with smallest angle, rinse and repeat. Will try to patch up this over weekend 🙂