I am creating similar properties list.
I have to look for the 4 similar range properties in the list.
- If the price is $400,000 then I have to find 4 properties of $400,000 price.
If the 4 properties could not be found then
- Sort the list high to low and find the remaining properties from the list.
If there are no same price properties then
Sort the list from high to low and get two properties from the list
And again sort the list low to high and get the 2 properties from the list
In order to find the same price properties
var properties = props.results.Where(x => x.Price== price).ToList().Take(4); High to low list
var highToLow = props.results.OrderByDescending(x => x.Price).ToList().Take(4); Low to high list
var lowToHigh = props.results.OrderBy(x => x.Price).ToList().Take(4); The problem is
When there is less than 4 properties found from the same price properties
var properties = props.results.Where(x => x.Price== price).ToList().Take(4); Now I am sorting the list High to Low and finding rest of the properties from this High to Low list.
var highToLow = props.results.OrderByDescending(x => x.Price).ToList().Take(4); How can I combine the list ?
Has anyone done something similar to what I am trying to achieve. Any help or suggestion would be appreciated.
Thanks in advance
How can I combine the list ?ConcatorUnion.