If you open up the palettes tab
Windows->Dockable Dialogs->Palettes , you will note that the colormap for any opened indexed image is ready to be used as a palette (if you want such a palette to become a permanent asset, just use the
duplicate button on it, available at the bottom of the dialog).
To use those colors on another image, there are two options:
1 - color likeness mapping: Starting with an image in
RGB mode (convert its mode back to RGB if it is indexed or grayscale,
Image->Mode->RGB), convert the image to indexed -
Image->Mode->Indexed - on the dialog that shows, pick the option to
Use custom palette and choose the Palette of your source image.
If you need the palette from the source image to be in a particular order other than the one it is put in (for example, ascending value of colors), duplicate the colormap palette of your source image (so that it is independently editable) and on the context menu of the Palette list dialog, use the
Sort palette... option.
2 - color by color index number: With your target image already in indexed mode (convert to indexed as above, but use
Generate optimum palette instead), use the option
Colors->Map->Set Color Map... and pick the palette that represents the colormap of your source image.
3 - For mapping the Value (HSV) from your target image to colors on the corresponding indexes of the target palette (as opposed to a proximity algorithm that includes Hue like (1) or overwritting the color map, as in (2): convert your target image to grayscale (
Image->mode->grayscale) and them use