对双打的ObservableCollection进行排序 [英] Sort a ObservableCollection of Doubles

查看:72
本文介绍了对双打的ObservableCollection进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在开发一个从csv文件解析colomn的项目。



我存储我的数据:



csv文件:



A1; A2 ; A3; A4;



B1; B2; B3; B4;



..; ..; ..; ..;



我的班级:



Hello,

I'm working on a project which parse colomn from a csv file.

I store my datas like that :

csv file :

A1 ; A2 ; A3 ; A4;

B1 ; B2 ; B3 ; B4;

.. ; .. ; .. ; .. ;

My class :

public class Restaurant
   {
       public double X1 { get; set; }
       public double X2{ get; set; }
       public double X3{ get; set; }
       public double X4{ get; set; }
   }

public class ORestaurant
   {
       public ObservableCollection<Restaurant> OCollection_Restaurant { get; set;
   }





解析后,OCollection_Restaurant包含很多餐馆。



我想按特定列对它们进行排序(所以餐馆的特定属性)



我试过这个:





After parsing, OCollection_Restaurant contains a lot of "restaurants".

I would like to sort them by a specific column ( so a specific attribute of restaurants)

I tried with this :

public class ligne : IComparable<ligne>
    {
        public double nresto;
        public double Int_row;
        public ligne(double num_resto, double my_row)
        {
            nresto = num_resto;
            Int_row = my_row;
        }
        public double CompareTo(ligne other)
        {
            return nresto.CompareTo(other.nresto);
        }
    }





它适用于Ints但不适用于双打。



我想做同样的想法。



你能帮我吗?



谢谢!



It works fine with Ints but not with Doubles.

I would like to do the same think.

Can you help me please?

Thanks !

推荐答案

你可以看看:

如何对可观察的集合进行排序? [ ^ ]

对ObservableCollection(Reactive Extensions)的值进行排序 [ ^ ]
You can have a look at:
How do I sort an observable collection?[^]
Sorting values of ObservableCollection (Reactive Extensions)[^]


这篇关于对双打的ObservableCollection进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆