반응형
C # 목록. 내림차순
'Product.Name' 별로 정렬 된 목록 을 내림차순 으로 받고 싶습니다 .
아래의 기능과 마찬가지로 목록을 오름차순으로 정렬하는 것이 역순으로 가능합니까?
var newList = list.OrderBy(x => x.Product.Name).ToList();
확실한:
var newList = list.OrderByDescending(x => x.Product.Name).ToList();
Doc : OrderByDescending (IEnumerable, Func) .
귀하의 의견에 대한 답변 :
var newList = list.OrderByDescending(x => x.Product.Name)
.ThenBy(x => x.Product.Price)
.ToList();
예. OrderByDescending
대신에 사용하십시오 OrderBy
.
list.OrderByDescending();
나를 위해 작동합니다.
var newList = list.OrderBy(x => x.Product.Name).Reverse()
이 작업을 수행해야합니다.
내 프로젝트 에서이 코드 조각을보십시오.
모델 내부의 속성을 기준으로 목록을 다시 정렬하려고합니다.
allEmployees = new List<Employee>(allEmployees.OrderByDescending(employee => employee.Name));
하지만 a 문제가 발생하여 문제 small and capital letters exist
를 해결하기 위해 문자열 비교기를 사용했습니다.
allEmployees.OrderBy(employee => employee.Name,StringComparer.CurrentCultureIgnoreCase)
list = new List<ProcedureTime>(); sortedList = list.OrderByDescending(ProcedureTime=> ProcedureTime.EndTime).ToList();
내림차순으로 정렬 된 시간을 표시하는 데 효과적입니다.
참고 URL : https://stackoverflow.com/questions/3925258/c-sharp-list-orderby-descending
반응형
'Programing' 카테고리의 다른 글
github (시간 / 일)의“실제”커밋 날짜 참조 (0) | 2020.06.20 |
---|---|
py.test 테스트를 실행하도록 PyCharm을 어떻게 구성합니까? (0) | 2020.06.20 |
IEnumerable에서 첫 번째 요소를 얻는 방법 (0) | 2020.06.20 |
mysql 클라이언트 (Linux) 만 설치하는 방법이 있습니까? (0) | 2020.06.20 |
PHP에서 Null vs. False vs. 0 (0) | 2020.06.20 |