not only that, the ranking is also defined by the overall activity in the sub-reddit it is posted in. So you can see a post with fewer upvotes, posted later over a post which has a lot more upvotes posted earlier. Which means, even submissions to very small sub-reddits have a decent chance to be promoted to trending and to r/all even
The trending or 'hot' algorithm is a bit different than the "top" algorithm.
I believe you're referring to the 'hot' algorithm which is meant to take velocity into account. Velocity tries to abstract away contextual factors like subreddit activity, number of votes, etc. and represent how quickly, relative to number of participants, a post is 'rising'.
The 'top' algorithm, however, is purely a factor of total vote (up - down) + time.