所以我有一个独特的问题。说我有以下代码:
List<Vector3> locations = new List<Vector3> ();
locations.add(new Vector3(1,1,0));
locations.add(new Vector3(1,2,0));
locations.add(new Vector3(1,3,0));
locations.add(new Vector3(2,1,0));
locations.add(new Vector3(3,2,0));
locations.add(new Vector3(3,8,0));
现在我想对此列表进行排序,并根据以下事实删除项目:我只希望列表中的项目代表每个x值的y值最低。
因此,在排序代码之后,我在上面的示例列表中唯一的Vector3是:
1,1,0
2,1,0
3,2,0
非常感谢您的帮助!
答案 0 :(得分:0)
这是我为获得正确的排序路径所做的工作。如果有更有效的方式让我知道。
SELECT MEMBERS.scancode, MEMBERS.fname, MEMBERS.lname, MEMBERS.datejoin, MEMBERS.entrydate
, MEMBERS.relationship, MEMBERUDFS.udfvalue
FROM MEMBERS
LEFT JOIN MEMBERUDFS
ON MEMBERS.memid = MEMBERUDFS.memid
AND MEMBERUDFS.udfid = '17'
LEFT JOIN MEMBERUDFSETUPS
ON MEMBERUDFS.udfid = MEMBERUDFSETUPS.udfid
WHERE (MEMBERS.siteid = @rvSite
AND MEMBERS.status = 'A'
AND MEMBERS.relationship = 'M'
AND MEMBERS.datejoin BETWEEN @rvStartDate AND @rvEndDate
AND MEMBERS.mtypeid NOT IN (5, 6, 7, 11, 14, 31))
OR (MEMBERS.siteid = @rvSite
AND MEMBERS.relationship = 'P'
AND MEMBERS.entrydate BETWEEN @rvStartDate AND @rvEndDate)
答案 1 :(得分:0)
locations = locations.OrderBy(v => v.x).ToList();
您可以使用以下方法按x升序对位置Vector3 []进行排序:
locations = locations.OrderBy(v => v.x).ToArray<Vector3>();