Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

sorting problem

On my real estate site at
http://www.lakemonticelloproperties.com

I'm using the sortDescend By in my loop to display the listings from most expensive to least expensive.

Here's the code:
{$foreach x in (folder "Listings")SortDescendBy .extra1$}
<div class="listings"><A href="{$x.link$}"><IMG height=120 src="{$x.extra2$}" width=160 border=1></A><br>{$x.teaser$}<br>{$x.extra1$}<br>&nbsp;</div>
{$next$}

I have the price in the extra1 field. With a $ in it.

All the properties are six digits with a comma, like $123,000, and it was working perfectly, until I added a property that costs $9,900.

It's putting that property FIRST, instead of last, before listings that have no price.

I did a little test in Access, sticking prices that include dollar signs in a table, and sorted, and it does it correctly.

I tried taking the dollar signs out, and adding them in the code, but that doesn't work, because the dollar sign displays on some listings that have no price, and I don't want that.

Am I making a mistake, or is a bug?

Debra Weiss
Saturday, January 19, 2002

I think it's doing alphabetic sort.  It doesn't recognize your extra1 contents as numbers.  If you sort in descending order, a price of $99 will will sort to the top while $10,000,000 will sort to the bottom.

Anyway that what it does for me.  Looks like date is the only thing that gets "sorted by the numbers."  Even if you leave out the dollar signs and commas, City still doesn't recognize them as numbers.

TK
Saturday, January 19, 2002

Okay, then. I just added a space before the price, and that's fixed it. Thanks Terry.

Debra Weiss
Saturday, January 19, 2002

*  Recent Topics

*  Fog Creek Home