• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sort version number field

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic