rows are rendered not in serial order as appeared in database an wondering why my data though in serial order by id when i look at the records in the database but when rendered, they are not in order of id?

for example:
database

id animal
1  dog
2  lion
3  tiger


html View on the browser

id  animal
2   lion
1   dog
3   tiger
As @a_horse_with_no_name already said: the data may not be stored in the sequential order.

You have some choices: 


Use a ORDER BY id[1] clause and force the database to sort the data for you.
Force a CLUSTER[2] on the table to rewrite the data and sort based on a index as you want. I don't recommend that as a solution for your question but it is a alternative. IMPORTANT: CLUSTER command only will physically sort the data on the disk, rewriting the data files based on the index. There is no guarantee of the data will be returned on the same order.


Hope it helps.

References:


https://www.postgresql.org/docs/current/static/queries-order.html
https://www.postgresql.org/docs/current/static/sql-cluster.html