I have the Model Chapter:
class Chapter(ndb.Model):
tutKey = ndb.KeyProperty(kind='Tutorial')
title = ndb.StringProperty(required=True)
content = ndb.TextProperty(required=True)
note = ndb.TextProperty()
lvl = ndb.IntegerProperty(default=0)
order = ndb.IntegerProperty(default=0)
parentID = ndb.KeyProperty(kind='Chapter')
number = ndb.IntegerProperty()
'number' is the base chapter (chap1 or chap 1.2 have number = 1). 'lvl' is for the depth of the chapter, for example, in chap1.1.1 the lvl is 3 and in chap1.1.1.1 lvl is 4. And the 'order' says the order of the chap, for example, in chap1.2 'order' is 2 and in chap2.2 'order' is also 2.
How can i sort the following chapters (for example)?
chapter 2
chapter 2.1
chapter 1.1.1
chapter 1.1
chapter 1
I have been thinking... should i create a StringProperty to save the chapter number like "1.2.1" and then split the string by '.' ?
EDIT: i created a ndb.IntegerProperty(repeated=True) the equivalent to ListProperty suggested by JBernardo. I'm able to store the data correctly, but I can't get a way to sort by the property. Anyone knows how to do this?