两个List,第二个List根据第一个List排序

/// <summary>

        /// 协同排序

        /// </summary>

        /// <param name="sod"></param>

        /// <param name="dis"></param>

        /// <returns></returns>

        private List<int> oids(List<int> sod, List<double> dis)

        {



            for (int tmpi = 0; tmpi < dis.Count; tmpi++)

            {

                //找到最小的id

                int lid = tmpi;

                for (int tmpj = tmpi + 1; tmpj < dis.Count; tmpj++)

                {

                    if (dis[lid] > dis[tmpj])

                    {

                        lid = tmpj;

                    }

                }

                //互换最小的与当前

                double ti = dis[lid];

                int tname = sod[lid];

                dis[lid] = dis[tmpi];

                dis[tmpi] = ti;

                sod[lid] = sod[tmpi];

                sod[tmpi] = tname;

            }



            return sod;

        }

 

你可能感兴趣的:(list排序)