Upon page load everything in Drupal7 occurs in specific order and this ordering is dependent on a Modules, or Hooks weight. Sometimes if we want to change the default behavior or Drupal or other modules we must be aware of this aspect of Drupal. One way to visualize the ordering of module priority in Drupal is to install the Modules Weight module.
The ordering of the module list found at /admin/config/system/modules-weight is the ordering from Top to Bottom which Drupal will invoke modules by. Hooks defined within modules run in the ordering of this list.
By clicking Show Row Weights at the upper right of the table you can see the Weight of the module in the Drupal system. You will see that some modules have an identical weight as other modules. For example in my screenshot a ton of modules are assigned the weight value of 0. Modules assigned the same weight are invoke in alphabetical order based on their machine name.
The modules_weight module allows you to easily to drag-and-drop a module to a different weight — and therefore adjust its invocation order within your Drupal installation. You should be careful when doing this, as it could irrevocably break the system, but with care this can be very powerful. In a future blog post I will make use of this flexibility of Drupal7.
If you want to change the order of your module, without requiring an install of this module (which some might consider bloating your Drupal installation) you can see techniques for assigning weights this in the Drupal Community documentation. Essentially it is a line of code in your module’s .install file.