This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes MongoDB and the fly likes Sort version number field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » MongoDB
Bookmark "Sort version number field" Watch "Sort version number field" New topic
Author

Sort version number field

Zeba Ahmad
Greenhorn

Joined: Nov 07, 2013
Posts: 1
Hi,

Our application is based on MongoDB. We store the "names", "versions" and various attributes of IT assets in MongoDB. We have a new search requirement in which we need to retrieve the latest version of assets based on keywords. The catch here is that my versions numbers are of the format
x.y.z (i.e. major.minor.maintenance)

Basically, I should have the result set sorted first by major version (desc), then minor version (desc) and then maintenance version (desc).
e.g. For the version numbers given below:
1.0.10
1.1.0
11.0.0
2.0.1
The sorted version should be:
1.0.10
1.2.10
2.0.1
11.0.0
Is it possible for me to sort this correctly at Mongo layer itself? Unfortunately the version number is just stored as a single string value, and not a structured object in the x.y.z format.

Thanks in advance!
Zeba
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sort version number field