Live data from Hacker News

Bubble sort in pure CSS

dev.to

11–20 of 73 posts

Re: Bubble sort in pure CSS

#12
post #2

> Editor’s Note: This article ends on a cliffhanger. The next part goes out in a week I stopped reading there. Let us know when the second part is out. Why write half an article?

I guess you're on mobile, and your finger landed on a neighboring article.

Re: Bubble sort in pure CSS

#13
post #6
post #4

It seems to only work for a fixed size. Wouldn’t that be called a sorting network?

It is a sorting network corresponding to bubble sort on 5-element input. It is actually pretty good - the code uses 10 comparisons, while the optimal sorting network for 5 elements uses 9: https://bertdobbelaere.github.io/sorting_networks.html#N5L9D...

That’s a cool page! Thanks!

Re: Bubble sort in pure CSS

#14
post #5

> (oneIsGreater * origArray[0]) + (twoIsGreater * origArray[1]) There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition. There is not much difference between this and: (oneIsGreater ? origArray[0] : 0) | (twoIsGreater ? origArray[1] : 0) This is often useful to think about when working on bitset or SIMD algorithms.

> There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition.

Really? The connection between AND and multiplication is obvious, but disjunction doesn't behave like addition. (For one thing, just like AND, it destroys information, which multiplication does do and addition doesn't.) Addition would usually be XOR.

In fact, AND and XOR are what you get when you apply multiplication and addition to the integers (mod 2).

Re: Bubble sort in pure CSS

#16
post #5

> (oneIsGreater * origArray[0]) + (twoIsGreater * origArray[1]) There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition. There is not much difference between this and: (oneIsGreater ? origArray[0] : 0) | (twoIsGreater ? origArray[1] : 0) This is often useful to think about when working on bitset or SIMD algorithms.

> There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition. Really? The connection between AND and multiplication is obvious, but disjunction doesn't behave like addition. (For one thing, just like AND, it destroys information, which multiplication does do and addition doesn't.) Addition would usually be XOR. In fact, AND and XOR are what you get when you ap…

It's called logical addition which is different than arithmetic addition, so it's best to not conflate the two. It's called "addition" because you "add" another propostion, creating a disjunction. And by the rules of logic, as long as the original proposition was true, the truth value is preserved no matter how many propositions you introduce (or "add").

    A ⊢ ((A ∨ B) ∨ C) ... ∨ n

Re: Bubble sort in pure CSS

#17
post #11

This is scary good. Well done. If your product have any frontend and you have the power to decide ensure at least one of your hires can write CSS at this level.

This is a fun proof of concept, but it isn't what CSS is used for. There's no conceivable reason you'd do this in practice.

Re: Bubble sort in pure CSS

#18
post #16

Earlier quoted context omitted.

> There is a reason why conjunction (AND) is also called logical multiplication, and disjunction (OR) logical addition. Really? The connection between AND and multiplication is obvious, but disjunction doesn't behave like addition. (For one thing, just like AND, it destroys information, which multiplication does do and addition doesn't.) Addition would usually be XOR. In fact, AND and XOR are what you get when you ap…

It's called logical addition which is different than arithmetic addition, so it's best to not conflate the two. It's called "addition" because you "add" another propostion, creating a disjunction. And by the rules of logic, as long as the original proposition was true, the truth value is preserved no matter how many propositions you introduce (or "add"). A ⊢ ((A ∨ B) ∨ C) ... ∨ n

> It's called "addition" because you "add" another propostion, creating a disjunction.

By that argument, conjunction is also called "addition". Perhaps there's a different reason?

The choice of terminology, contrasting "logical addition" with "logical multiplication", obviously indicates that logical addition is supposed to be analogous to addition. What is the analogy?

Re: Bubble sort in pure CSS

#19
post #2

> Editor’s Note: This article ends on a cliffhanger. The next part goes out in a week I stopped reading there. Let us know when the second part is out. Why write half an article?

Where does that text appear in the article? I learned from the article and found the subject interesting, but the breathlessly excited tone and forced cuteness were offputting.

Oops! Sorry all!

Re: Bubble sort in pure CSS

#20
post #2

> Editor’s Note: This article ends on a cliffhanger. The next part goes out in a week I stopped reading there. Let us know when the second part is out. Why write half an article?

Where does that text appear in the article? I learned from the article and found the subject interesting, but the breathlessly excited tone and forced cuteness were offputting.

I can't wait for "tone it down" AI button in the next chrome version.
Post reply on HN