DEV Community

Cover image for Bubble Sort...in PURE CSS? [No JS] 😱

Bubble Sort...in PURE CSS? [No JS] 😱

GrahamTheDev on October 14, 2023

Imagine you are in an interview and you get asked "can you implement bubble sort"...and you answer the interviewer "sure, do you want that in JavaS...
Collapse
 
savvasstephnds profile image
Savvas Stephanides

Bogosort next πŸ”₯

Collapse
 
zippcodder profile image
Deon Rich

Canvas of babel with pure CSS πŸ˜‚

Collapse
 
grahamthedev profile image
GrahamTheDev

Haha, that scares even me! πŸ€£πŸ’—

Collapse
 
grahamthedev profile image
GrahamTheDev

Haha, I might actually do it. Although I may run into a limitation on the number of iterations etc.

Fun idea though! πŸ€£πŸ’—

Collapse
 
savvasstephnds profile image
Savvas Stephanides

Or, if you're lucky enough, it might all get sorted in the first try. Literally the only sorting algorithm that has the potential to do so πŸ˜…πŸ˜…πŸ˜…

Thread Thread
 
grahamthedev profile image
GrahamTheDev

Anywhere from O(1) to O(infinity) πŸ€£πŸ’—

Thread Thread
 
tanzimhossain2 profile image
Tanzim Hossain

😁

Collapse
 
aminmansuri profile image
hidden_dude

You sir are an evil genius..

Next up we expect to see your implementation of Doom in CSS.

Collapse
 
link2twenty profile image
Andrew Bone

πŸ˜… if this was a valid reaction I'd have used it rather than heart.

There is a proposal for css var arrays (with CSS random too) so you might have to revisit this someday πŸ˜‰

Collapse
 
grahamthedev profile image
GrahamTheDev

Yeah that would probably make this 200 times easier and actually performant...but then it wouldn't be fun anymore! πŸ€£πŸ’—

Collapse
 
tanzimhossain2 profile image
Tanzim Hossain

What about the time complexity for this?

Collapse
 
grahamthedev profile image
GrahamTheDev

O(n2) it is just bubble sort! πŸ€£πŸ’—

Collapse
 
tanzimhossain2 profile image
Tanzim Hossain

πŸ‘Œβ€οΈ

Collapse
 
maxfindel profile image
Max F. Findel

This is amazing 🀯 I'm impressed that you didn't mess up that very copy&paste-intensive code (if you did, I bet it was hell to debug) πŸ˜†

Collapse
 
tylim88 profile image
Acid Coder

No wayπŸ’€

Collapse
 
mangor1no profile image
Mangor1no

aint no way bruh...

Collapse
 
grahamthedev profile image
GrahamTheDev

Waaaay doood! πŸ€£πŸ’—

Collapse
 
commonsenseal profile image
Albert Wiersch

Wow... that is crazy but also impressive, and all that CSS even passes CSS HTML Validator with no errors!

Collapse
 
grahamthedev profile image
GrahamTheDev

My CSS is always valid...even the stuff that isn't useful like this! πŸ€£πŸ’—

Collapse
 
zippcodder profile image
Deon Rich

Wow thats insane!! Fascinating post!! You can definitley do some cool stuff with CSS if you know what you're doing!

Collapse
 
grahamthedev profile image
GrahamTheDev

Yeah, but at the same time, it is far less stressful to do it in a proper language! πŸ€£πŸ’—

Collapse
 
loremimpsu profile image
Lorem Impsu

ow congrats, great post!

Collapse
 
grahamthedev profile image
GrahamTheDev

πŸ™πŸΌπŸ’—

Collapse
 
grahamthedev profile image
GrahamTheDev

Ooohhh, we are number 9 in the series!

Number 10 should be fun...Conway's game of life...in pure HTML! πŸ€£πŸ’—