Add basic popular sorting function implemented in mysql