0

My current comment reply system:

1
 1.1
 1.2
  1.2.1
10
2
 2.1

I can sort the comments from table by their ids (as above) and indent depending on the number of dashes.

The problem is that '10' comes right after '1.2.1'. Is it possible to sort values such as '1.2.1' as a number and not string? Does any number data type excepts multiple dots or commas?

Thanks in advance!

1 Answer 1

2

The common way in materialized path trees is to pad ids to a N-digit number with zeros so it comes 00001 etc

00001
 00001.00001
 00001.00002
  00001.00002.00001
00002
 00002.00001
00010
Sign up to request clarification or add additional context in comments.

4 Comments

That's the first thing I thought about, but then there's a limit to number of comments at one level.
@Jure: yes, it is a limit. If you worry you'll get 100k comments to one node - then you can pad it to 6 digits. Anyway, I never seen so huge trees and I think that 100k is enough for everything.
Yeah, I know it's silly :P, but I'm just trying to find a way to make it without limit for the sake of it. Is there any noticeable difference in performance between querying 1000 'x.x.x' and 'xxxxx.xxxxx.xxxxx' type values? Just curious...
@Jure: it is, but very small.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.