MegaPixel does not really matter like if you go just by that then LeEco Le Max 2 or something had the biggest MP count in its range, top of the line specs on everything in the box, and was still a trash phone.
Now most smartphones use sensors by either Samsung or Sony. Apart from the top of the line sensors, the specifications are similar and are even interchangeable, so some entry level phones may have some sensors from Sony, and others by Samsung. As a consumer, whether you are buying the top end or low end phone, this strictly should not matter.
Now how can these manufacturers offer increasing MP size in smaller sensors? It is because each individual imaging element (pixel) on the sensor is getting smaller. This does not translate to better picture quality. Think of the shower of photons that leads to getting an image as a rainfall. You can have a large array of big buckets (dSLRs), a small array of big buckets (bridge/prosumer), or a small array of small cups (smartphones). The imaging quality is dependent on the total amount of light or water captured. So although the smartphones have more cups (higher MP), the bigger dSLRs capture more light (or rain) with a reduced MP count. HTC UltraPixel sensors have individual imaging elements that are more than twice the size of competition from Samsung and Sony, and are able to capture more light, and deliver a better image quality. However, they lose out in other departments such as low light imaging and video, even though technically they should not, because of AI processing in Huawei, Pixel Samsung and Apple phones, and are not considered among the best cameraphones around. Nokia and Panasonic have packed in some ridiculously large sensors in older devices, that were well ahead of their time.
Now, the next important thing to understand here is the arrangement of the individual pixels on the sensors. Older phones used something called as a quad bayer filter, which was an array with one red pixel, one blue pixel, and two green pixels. This is an incredibly fascinating topic to get into (human perception and colour vision), but essentially we can see green text on black better than blue or red, and like most of the content that we consume is best represented with such an arrangement (read the skin tones of people). While this is a good arrangement for human use, it is not accurate in terms of the actual colour information, and as such the arrangement is not used in scientific instruments or spacecraft (think Cassini or Hubble). In any case, smaller sensors meant that smartphone companies had to cheat and came up with what is known as a quad bayer array, where the pixels are arranged in a matrix of four imaging elements replacing what was previously a single pixel. This means that the block of four pixels can behave like a single pixel when required, allowing for better low light performance, and higher dynamic range. Both Samsung and Sony use the same arrangement. Samsung brands it as "tetracell" when selling their sensors to smartphone companies, and smartphone companies may use any word they please to talk of the same thing. Does it improve performance? Well, yes, in some cases, but only because they need to do that because of their teeny tiny sensors and their larger batteries and multiple lenses and selfie shooters and notched displays.
*i.imgur.com/LzfUnxV.jpg
So what are the main points here?
1. The amount of light falling on the sensor decides the image quality, not the MP count. This depends on the size of the sensor, the size of the individual imaging elements, and the arrangement of the imaging elements on the sensor.
2. Notched displays, reducing real estate, multiple lenses are all exerting pressure on smaller sensors with increased MP count. While quality of images are improving in smartphones, the progress is not as good as it would be if these pressures did not exist. Occasionally, a smartphone brand may come up with an innovative design that bucks the trend, but these are soon forgotten.
3. The best cameras are in the top end Samsung, Huawei, Apple and Google devices.