need to OrderBy price, how to move zero to the end of the results

Vote:
 

I'm returning search results ordered by price. I've been asked to move everything with a price of zero to the end of the results. I know this should be easy but I seem to be missing how to accomplish this. Any suggestions?

        public static ITypeSearch<ICommunitySearch> OrderByLowestPrice(this ITypeSearch<ICommunitySearch> search)
        {
            search = search.OrderBy(i => i.LowestPrice());

            return search;
        }
#259935
Aug 02, 2021 21:47
Vote:
 

Hi Kenny,

Yeah it does sound easy but i dont think it is using the Find API!

To make it work - you probably need to modify your LowestPrice() convention to hard set a very high hardcoded price in the Find index for zero priced products. The orderingby Lowest Price woudl then have these at the end of the result. That would meet your requirement although it is not tidy.

Thanks

#259984
Aug 03, 2021 14:51
Vote:
 

Hi Johnny, I came to similar conclusions after posting this. I substituted Double.MaxValue for every zero and things worked as expected.

#259989
Aug 03, 2021 21:21
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.