added csv writer, fixing compare method, changed to sorted permission list