← back to Commercialrealestate
mls viewer: default landing sorts newest-first (days-on-market asc); missing values sink to bottom in all sorts
70f8f1fb8900a0eb39bf4b5a0ff1f0005e2a7b96 · 2026-07-30 21:24:01 -0700 · Steve Abrams (DW)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 70f8f1fb8900a0eb39bf4b5a0ff1f0005e2a7b96
Author: Steve Abrams (DW) <steve@designerwallcoverings.com>
Date: Thu Jul 30 21:24:01 2026 -0700
mls viewer: default landing sorts newest-first (days-on-market asc); missing values sink to bottom in all sorts
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
public/mls.html | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/public/mls.html b/public/mls.html
index ff667c2..72244f1 100644
--- a/public/mls.html
+++ b/public/mls.html
@@ -158,7 +158,7 @@ const COLS=[
{k:'composite',l:'Score',t:'n'},
{k:'source',l:'Source',t:'link'},
];
-let DATA=[], view='table', sortKey='rank', sortDir=1, q='';
+let DATA=[], view='table', sortKey='dom', sortDir=1, q=''; // default landing: freshest listings first (days-on-market asc); localStorage overrides for returning users
const _rd=(function(){ const v=parseInt(localStorage.getItem('mlsRecentDays'),10); return (v>0&&v<=365)?v:7; })();
const F={types:new Set(),cities:new Set(),status:new Set(),pmin:null,pmax:null,unwarrantable:false,nonqm:false,shortlist:false,justsold:false,justlisted:false,inescrow:false,fellout:false,pricecut:false,recentDays:_rd};
const daysSince=d=>{ if(!d) return Infinity; const t=Date.parse(d); return isNaN(t)?Infinity:(Date.now()-t)/86400000; };
@@ -302,8 +302,11 @@ function filtered(){
const c=COLS.find(x=>x.k===sortKey)||COLS[0];
rows=rows.slice().sort((a,b)=>{
let x=cval(a,c), y=cval(b,c);
- const xn=(x!=null&&x!==''&&!isNaN(+x)), yn=(y!=null&&y!==''&&!isNaN(+y));
- if(xn&&yn){ x=+x; y=+y; } else { x=String(x==null?'':x).toLowerCase(); y=String(y==null?'':y).toLowerCase(); }
+ // missing values always sink to the bottom, regardless of sort direction
+ const xm=(x==null||x===''), ym=(y==null||y==='');
+ if(xm&&ym) return 0; if(xm) return 1; if(ym) return -1;
+ const xn=(!isNaN(+x)), yn=(!isNaN(+y));
+ if(xn&&yn){ x=+x; y=+y; } else { x=String(x).toLowerCase(); y=String(y).toLowerCase(); }
if(x<y) return -1*sortDir; if(x>y) return 1*sortDir; return 0;
});
return rows;
← 47bee70 mls viewer: land populated (all 22,948 listings) instead of
·
back to Commercialrealestate
·
rename user-facing 'MLS' -> 'LA County Listings' (Redfin-sou 7eaf438 →