← Home BP Β· 7-9 🌷

Garden Sorter

82
Day 1 πŸ”₯
🎯 Today's Missions
🌷 πŸ¦‹ β˜€οΈ 🐞
🌷
Blossom Garden Universe
Garden Sorter
The Garden Show starts in one hour β€” but the line-up is a MESS! 🌷 Tall, tiny, medium… all jumbled together. Meet .sort(), the coach superpower that asks two flowers "who comes first?" and lines the WHOLE row up in perfect order. Pick your compare rule, flip it to reverse, even sort by PETALS β€” and save the show! 🌻

🌷 What we're MAKING today: My Garden Show

In Treasure Filter you met .filter() β€” it KEEPS only some items. Yesterday in Petal Parade, .map() CHANGED every item. Today the trio is complete: .sort() keeps every item, keeps each one exactly the SAME β€” it only changes the ORDER!

How? You give sort ONE compare rule. The coach walks down the row asking two flowers: "who comes first?" The rule a.height - b.height whispers "smaller steps LEFT!" β€” so the whole garden lines up small β†’ tall. Flip it to b.height - a.height and the line-up REVERSES. Same flowers, new order!

πŸ”— Last time (Petal Parade) you transformed every bud with .map(). Today: nobody gets dropped, nobody gets painted β€” 5 flowers in, 5 flowers out, standing in a PERFECT line. That's .sort()! 🌷
garden.js JavaScript

    
πŸ’‘ Tap compare rules below β€” watch this line change LIVE! .sort() changes the ORDER
garden stage LIVE
🌷 WAITING FOR RULE
πŸ“ LINE-UP MACHINE
Tap a compare rule, then press β–Ά Run Line-Up β€” every flower takes its place!
β†’ Flowers in
5
In order ↣
β€”
πŸŽ–οΈ Garden rank
Seedling 🌱
Challenge 1 / 5
Morning Staircase! Line up every flower small β†’ tall…
🧩 Tap ONE compare rule for the coach PICK ONE
🌷 Compare rules tell the coach WHO comes first. The code line updates the moment you tap!
πŸ“‹ Your 5 Garden Challenges
0 of 5 challenges lined up
🌷
You Mastered Garden Sorter!
One compare rule, one perfect line β€” you ran the Garden Show like a true Line-Up Coach. The judges are standing and the butterflies are cheering! πŸ¦‹πŸŒ·

πŸ’« What You Learned

  • .sort() puts every item in ORDER β€” smallest β†’ biggest (or the flip!)
  • The compare rule a.height - b.height whispers "smaller steps LEFT" β€” flip it to b.height - a.height to reverse the line-up
  • 5 in β†’ 5 out: sort never drops items (.filter() does) and never changes them (.map() does) β€” it only re-orders!
  • You can sort by ANY property β€” height today, petal count too!
  • Real coders .sort() data every day β€” names Aβ†’Z, scores highβ†’low. Now you do too! 🌷
🌷 Your Creation
My Garden Show
🌷 Come Back Tomorrow!
Next up: Monster Maker β€” meet OBJECTS! You already used them today: each flower was a little packet of labelled facts (height, petals). Tomorrow you BUILD your own monster object β€” name, eyes, color β€” and change it live! πŸ‘Ύ
🏠 Home
Nice! πŸŽ‰