S
Sudip_inn
Guest
i got the below code to sort quarter
var list = new List<String>
{
"1Q 2014A",
"2Q 2014A",
"2012FY",
"1Q 2013A",
"2Q 2013A",
"4Q 2014A",
"4Q 2013A",
"2013 FYA",
"2011FY",
"3Q 2014A",
"3Q 2013A",
"2013FY",
"2010FY",
"2014 FYA",
};
var result =
list
.OrderBy( s => Regex.Match( s, @"\d\d\d\d" ).Value )
.ThenBy( s => Regex.Match( s, @"^.Q" ).Value + '5' )
.ThenBy( s => !Regex.Match( s, @"FYA$" ).Success )
.ThenBy( s => !Regex.Match( s, @"FY$" ).Success )
.ToList( );
1) why 4 \d has been used instead of one ?
2) why dot has been used after this ^ symbol ?
3) why not sign has been used here !Regex.Match( s, @"FYA$" ).Success )
if i did not use not sign then what will happen or what will be meaning then ?
please answer for my above questions. thanks
Continue reading...
var list = new List<String>
{
"1Q 2014A",
"2Q 2014A",
"2012FY",
"1Q 2013A",
"2Q 2013A",
"4Q 2014A",
"4Q 2013A",
"2013 FYA",
"2011FY",
"3Q 2014A",
"3Q 2013A",
"2013FY",
"2010FY",
"2014 FYA",
};
var result =
list
.OrderBy( s => Regex.Match( s, @"\d\d\d\d" ).Value )
.ThenBy( s => Regex.Match( s, @"^.Q" ).Value + '5' )
.ThenBy( s => !Regex.Match( s, @"FYA$" ).Success )
.ThenBy( s => !Regex.Match( s, @"FY$" ).Success )
.ToList( );
1) why 4 \d has been used instead of one ?
2) why dot has been used after this ^ symbol ?
3) why not sign has been used here !Regex.Match( s, @"FYA$" ).Success )
if i did not use not sign then what will happen or what will be meaning then ?
please answer for my above questions. thanks
Continue reading...