Assume you have vector of 100 daily returns. Then, you can order them from largest to smallest or smallest to largest. When talking about returns, we are worried about the asset moving down, not up, so the risk we are examining is the risk associated with the low returns. (Either end of the vector, i.e., left or right side of the distribution based on whether you sort lowest to highest or highest to lowest.)
Now, since you have 100 returns, each return has a probability of 1/100, or 0.01.
Assume we are considering a confidence level of 95%. Then if you sorted lowest to highest, your 95th VaR would be the 6th lowest return, or the 6th value from the top of the sorted vector. Similarly, if you sorted highest to lowest, your 95% VaR would be the 94th elemect of the vector (the 6th element or 94th element isolote a 5% tail in both scenarios.)
Now to the easy part. The expected shortfall is simply the average of the returns beyond the VaR level. (To be precise, the Expected Shortfall is the Expected Value of the region beyond the VaR level.)
So in this example, the Expected Shortfall is the average of returns 1 through 5 if you sorted lowest to highest or the average of returns 96 through 100 if you sorted highest to lowest. In my example, which is an example of historical simulation, the probability of each return is 1 over the number or returns, i.e., 1/100, but in other cases, the probabilities might depend on a parametric distribution.