Initiative is a crucial aspect of combat in Dungeons & Dragons as it determines the order in which each creature takes their turn. When calculating initiative, there are a few things to note.
Each creature has an Initiative Bonus, which is equal to their Dexterity Modifier, plus any bonuses they have from feats, classes, and such, which will state the bonuses they grant. When initiative is called, each creature acts from highest initiative to lowest.
When two player characters have the same initiative, they may decide amongst themselves who goes first. The DM decides this for monsters that tie in initiative, and if a player and a monster tie. Instead of the above, your DM may use Dexterity Tiebreakers which means that when you roll a tie, you compare dexterity scores and whoever has the highest one wins, though further ties have you roll d20s and whoever rolls higher goes first, though you could also go at the same time should your DM allow it.
The various ways your DM could handle initiative are as follows:
Standard: Every creature rolls initiative at the start of combat by rolling 1d20 and adding their initiative bonus to the result, which determines the order each creature acts for the rest of combat.
Initiative Score: Each creature uses 10 + their Initiative bonus as their initiative roll, determining the order for each creature when combat starts.
Side Initiative: Each side of combat when it starts (party, monsters, villains, bystanders, and other groups that find themselves in combat) rolls a d20 with no modifiers, Re-rolling on ties. Once each creature has taken a turn, initiative advances to the next side, which takes all of their turns.
Speed factor: Every round, each creature starts by choosing an action. Then based on what they decide to do, apply bonuses and penalties to their rolls depending on the action they choose to take. After that, each creature rolls initiative and takes their turn, restricted in what they choose to do by what action they choose. After that, you start a new round and do it all over again.